Ejemplo n.º 1
0
 def test_build_max_heapify(self):
     for _ in range(50):
         array = create_random_array(-100, 100, randint(50, 100))
         hs.build_max_heap(array)
         self.assertTrue(hs.is_heap(array, 0))
Ejemplo n.º 2
0
 def test_max_heapify(self):
     series = ([], [1], [1, 2], [0, 5, 4, 3, 2, 1])
     for array in series:
         hs._max_heapify(array, 0, len(array))
         self.assertTrue(hs.is_heap(array, 0))
Ejemplo n.º 3
0
 def test_view_build_max_heap(self):
     array = create_random_array(-100, 100, 10)
     print_array(array)
     hs.build_max_heap(array)
     print_array(array)
     print(hs.is_heap(array, 0))
Ejemplo n.º 4
0
 def test_is_heap(self):
     series = ([], [1], [3, 1], [5, 4, 3, 2, 1])
     for array in series:
         self.assertTrue(hs.is_heap(array, 0)) 
     self.assertFalse(hs.is_heap([1, 3], 0))