We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Can't you just call heappop() for that? I don't really see how you can avoid calling heapify in some cases. Removing an element can change the structure of the heap. Which might affect later deletions. If using Python, isn't everyone just using heapq? If you use heappush you don't have to worry about heapify. Only have to heapify if deletion is a non-root node.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
Can't you just call heappop() for that? I don't really see how you can avoid calling heapify in some cases. Removing an element can change the structure of the heap. Which might affect later deletions. If using Python, isn't everyone just using heapq? If you use heappush you don't have to worry about heapify. Only have to heapify if deletion is a non-root node.