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.
Why? Because after a deletion, the code only does a bubble down from the deletion point. That means that from the parent of the deletion point, the heap may not be in heap order. The code should have tested if the new value of the deletion point was smaller than that of its parent and, if so, bubble up first before doing a bubble down.
It's fascinating that not a single one of the test cases checked for this outcome.
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 →
Interesting. My code does the same.
Why? Because after a deletion, the code only does a bubble down from the deletion point. That means that from the parent of the deletion point, the heap may not be in heap order. The code should have tested if the new value of the deletion point was smaller than that of its parent and, if so, bubble up first before doing a bubble down.
It's fascinating that not a single one of the test cases checked for this outcome.