示例#1
0
 def test_heap_sort(self):
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      max_heap_sort([1, 5, 65, 23, 57, 1232]))
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      min_heap_sort([1, 5, 65, 23, 57, 1232]))
示例#2
0
 def test_heap_sort(self):
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      max_heap_sort([1, 5, 65, 23, 57, 1232]))
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      min_heap_sort([1, 5, 65, 23, 57, 1232]))
示例#3
0
    def test_heap_sort(self):
        self.assertTrue(
            is_sorted(max_heap_sort([1, 3, 2, 5, 65, 23, 57, 1232])))

        self.assertTrue(
            is_sorted(min_heap_sort([1, 3, 2, 5, 65, 23, 57, 1232])))
示例#4
0
from algorithms.sort import max_heap_sort
import random
#ascending order

alist=[ random.randint(1,10) for i in range(100)]
print(alist)
sorted_list=max_heap_sort(alist)
print(sorted_list)