def test_heap_sort(self):
     """测试堆排序"""
     sort_result = binary_heap.heap_sort(list([0, 1, 2, 3, 4, 5, 6, 7]))
     self.assertListEqual(sort_result, list([7, 6, 5, 4, 3, 2, 1, 0]))
Esempio n. 2
0
 def test_reverse_sort_array2(self):
     self.assertEqual(
         [16, 14, 10, 9, 8, 7, 4, 3, 2, 1],
         heap_sort(data=self.array2, reverse=True)
     )
Esempio n. 3
0
 def test_sorted_value_of_array2(self):
     self.assertEqual(
         [1, 2, 3, 4, 7, 8, 9, 10, 14, 16],
         heap_sort(self.array2)
     )
Esempio n. 4
0
 def test_reverse_sort_array1(self):
     self.assertEqual(
         [11, 8, 6, 4, 3], heap_sort(data=self.array1, reverse=True)
     )
Esempio n. 5
0
 def test_sorted_value_of_array1(self):
     self.assertEqual([3, 4, 6, 8, 11], heap_sort(self.array1))