예제 #1
0
def timmerBubbleSort():
    sizeInput = []
    timer = []
    for i in range(2, 2000):
        sizeInput.append(i)
        temp = []
        for j in range(i):
            temp.append(random.randint(0, 100))
        start = time.time()
        main.bubbleSort(temp)  # call bubble sort function above
        end = time.time()
        timer.append((end - start))  # đơn vị time là 10^3 s

    pylab.plot(sizeInput, timer, 'o-')
    pylab.title("Bubble Sort")
    pylab.show()
예제 #2
0
 def test_one_element_array(self):
     self.assertEqual(bubbleSort(["1"]), ["1"])
예제 #3
0
 def test_equal_elements(self):
     self.assertEqual(bubbleSort(["a", "a", "a"]), ["a", "a", "a"])
예제 #4
0
 def test_empty(self):
     self.assertEqual(bubbleSort([]), [])
예제 #5
0
 def test_long_strings_special_symbol_different_cases(self):
     self.assertEqual(bubbleSort(["A!", "a!", "@a!"]), ["@a!", "A!", "a!"])
예제 #6
0
 def test_long_strings_special_symbol(self):
     self.assertEqual(bubbleSort(["!", "a!", "@a!"]), ["!", "@a!", "a!"])
예제 #7
0
 def test_long_strings_different_cases_2(self):
     self.assertEqual(
         bubbleSort(["bbF", "Aaa", "ABA", "Cba", "Bab", "bba"]),
         ["ABA", "Aaa", "Bab", "Cba", "bbF", "bba"])
예제 #8
0
 def test_long_strings(self):
     self.assertEqual(bubbleSort(["aaa", "aba", "aab", "bba"]),
                      ["aaa", "aab", "aba", "bba"])
예제 #9
0
 def test_simple_strings_special_symbol_and_numbers_and_register(self):
     self.assertEqual(bubbleSort(["a", "5", "!", "B"]),
                      ["!", "5", "B", "a"])
예제 #10
0
 def test_simple_strings_special_symbol(self):
     self.assertEqual(bubbleSort(["a", "A", "!", "B"]),
                      ["!", "A", "B", "a"])
예제 #11
0
 def test_simple_strings_different_register(self):
     self.assertEqual(bubbleSort(["a", "A", "B", "b"]),
                      ["A", "B", "a", "b"])
예제 #12
0
 def test_number_long(self):
     self.assertEqual(bubbleSort([5, 7, 4, 1, 8, 10]),
                      ([1, 4, 5, 7, 8, 10]))
예제 #13
0
 def test_numbers(self):
     self.assertEqual(bubbleSort([3, 1, 2]), [1, 2, 3])
예제 #14
0
 def test_simple_strings(self):
     self.assertEqual(bubbleSort(["b", "a", "c"]), ["a", "b", "c"])