Beispiel #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()
Beispiel #2
0
 def test_one_element_array(self):
     self.assertEqual(bubbleSort(["1"]), ["1"])
Beispiel #3
0
 def test_equal_elements(self):
     self.assertEqual(bubbleSort(["a", "a", "a"]), ["a", "a", "a"])
Beispiel #4
0
 def test_empty(self):
     self.assertEqual(bubbleSort([]), [])
Beispiel #5
0
 def test_long_strings_special_symbol_different_cases(self):
     self.assertEqual(bubbleSort(["A!", "a!", "@a!"]), ["@a!", "A!", "a!"])
Beispiel #6
0
 def test_long_strings_special_symbol(self):
     self.assertEqual(bubbleSort(["!", "a!", "@a!"]), ["!", "@a!", "a!"])
Beispiel #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"])
Beispiel #8
0
 def test_long_strings(self):
     self.assertEqual(bubbleSort(["aaa", "aba", "aab", "bba"]),
                      ["aaa", "aab", "aba", "bba"])
Beispiel #9
0
 def test_simple_strings_special_symbol_and_numbers_and_register(self):
     self.assertEqual(bubbleSort(["a", "5", "!", "B"]),
                      ["!", "5", "B", "a"])
Beispiel #10
0
 def test_simple_strings_special_symbol(self):
     self.assertEqual(bubbleSort(["a", "A", "!", "B"]),
                      ["!", "A", "B", "a"])
Beispiel #11
0
 def test_simple_strings_different_register(self):
     self.assertEqual(bubbleSort(["a", "A", "B", "b"]),
                      ["A", "B", "a", "b"])
Beispiel #12
0
 def test_number_long(self):
     self.assertEqual(bubbleSort([5, 7, 4, 1, 8, 10]),
                      ([1, 4, 5, 7, 8, 10]))
Beispiel #13
0
 def test_numbers(self):
     self.assertEqual(bubbleSort([3, 1, 2]), [1, 2, 3])
Beispiel #14
0
 def test_simple_strings(self):
     self.assertEqual(bubbleSort(["b", "a", "c"]), ["a", "b", "c"])