Пример #1
0
    def test_extract_min_maintains_the_heap_order(self):
        heap = MinHeap()
        heap.insert(1)
        heap.insert(2)
        heap.insert(3)
        heap.insert(4)
        heap.insert(5)

        self.assertEqual(heap.extract_min(), 1)
        self.assertEqual(heap.find_min(), 2)

        self.assertEqual(heap.extract_min(), 2)
        self.assertEqual(heap.find_min(), 3)
Пример #2
0
    def test_find_min_returns_the_minimum_data(self):
        minimum = 0
        heap = MinHeap()
        heap.insert(42)
        heap.insert(minimum)
        heap.insert(1)

        self.assertEqual(heap.find_min(), minimum)