We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 139d5d7 commit 95ec539Copy full SHA for 95ec539
pygorithm/data_structures/heap.py
@@ -2,10 +2,10 @@
2
# Contributed: OMKAR PATHAK
3
# Created On: 11th August 2017
4
5
-from queue import Queue
+from pygorithm.data_structures import queue
6
7
# min-heap implementation as priority queue
8
-class Heap(Queue):
+class Heap(queue.Queue):
9
def parent_idx(self, idx):
10
return idx // 2
11
@@ -27,7 +27,7 @@ def heapify_up(self):
27
Compare the rear item to its parent, swap if
28
the parent is larger than the child (min-heap property).
29
Repeat until the min-heap property is met.
30
-
+
31
Best Case: O(1), item is inserted at correct position, no swaps needed
32
Worst Case: O(logn), item needs to be swapped throughout all levels of tree
33
'''
0 commit comments