August 2024
Intermediate to advanced
516 pages
11h 47m
English
While the heap deletion algorithm seems straightforward, it once again raises the problem of the last node.
I explained that the first step of deletion requires us to move the last node and turn it into the root node. But how do we find the last node in the first place?
Before we solve the problem of the last node, let’s first explore why insertion and deletion are so dependent on the last node anyway. Why couldn’t we insert new values elsewhere in the heap? And why, when deleting, can’t we replace the root node with some other node other than the last node?
Now, if you think about it, you’ll realize that if we were to use other nodes, the heap would become incomplete. But this begs the next question: why ...
Read now
Unlock full access