Esempio n. 1
0
    def test_quicksort(self):
        for j in range(NUM_TESTS):
            l = rand_list(max_list=MAX_LIST)

            # no return!
            quicksort(l, prnt=False)
            assert_sorted(self, l)
Esempio n. 2
0
    def test_heapsort(self):
        for j in range(NUM_TESTS):
            l = rand_list(max_list=MAX_LIST)

            # no return!
            heapsort(l)
            assert_sorted(self, l)
Esempio n. 3
0
    def test_quicksort(self):
        for j in range(NUM_TESTS):
            l = rand_list(max_list=MAX_LIST)

            # no return!
            quicksort(l, prnt=False)
            assert_sorted(self, l)
Esempio n. 4
0
    def test_heapsort(self):
        for j in range(NUM_TESTS):
            l = rand_list(max_list=MAX_LIST)

            # no return!
            heapsort(l)

            for i in range(0, len(l) - 1):
                self.assertLessEqual(l[i], l[i + 1])
Esempio n. 5
0
    def test_quicksort(self):
        for j in range(10):
            l = rand_list(max_list=100)

            # no return!
            quicksort(l)

            for i in range(0, len(l) - 1):
                self.assertLessEqual(l[i], l[i + 1])
Esempio n. 6
0
    def test_heap_extract_extr(self):
        for j in range(NUM_TESTS):
            l = rand_list(max_list=MAX_LIST)
            build_heap(l)  # heapifies l in place
            out = []
            for i in range(0, len(l)):
                out.append(heap_extract_extr(l))

            for i in range(0, len(out) - 1):
                self.assertGreaterEqual(out[i], out[i + 1])
 def test_bubble(self):
     for j in range(NUM_TESTS):
         l = rand_list(max_list=MAX_LIST)
         l2 = bubble_sort(l)
         assert_sorted(self, l2)
Esempio n. 8
0
 def test_bubble(self):
     for j in range(NUM_TESTS):
         l = rand_list(max_list=MAX_LIST)
         l2 = bubble_sort(l)
         assert_sorted(self, l2)