def test_multiple_operations_maxheap(self): max_heap = MaxHeap(self.array) max_heap.add_element(5) self.assertEqual([11, 8, 6, 4, 3, 5], max_heap.elements()) self.assertEqual(11, max_heap.extract_root()) self.assertEqual([8, 5, 6, 4, 3], max_heap.elements()) max_heap.add_element([11, 13, 5, 6]) self.assertEqual([13, 6, 11, 5, 3, 6, 8, 4, 5], max_heap.elements()) self.assertEqual(13, max_heap.extract_root()) self.assertEqual(11, max_heap.extract_root()) self.assertEqual([8, 6, 6, 5, 3, 4, 5], max_heap.elements()) self.assertEqual([3, 4, 5, 5, 6, 6, 8], sorted(max_heap.elements()))
def test_extract_root_value_maxheap(self): max_heap = MaxHeap(self.array) self.assertEqual(11, max_heap.extract_root()) self.assertEqual([8, 4, 6, 3], max_heap.elements())