• + 0 comments

    Since deleting an element at any intermediary position in the heap can be costly, so we can simply replace the element to be deleted by the last element and delete the last element of the Heap.

    1. Replace the root or element to be deleted by the last element.
    2. Delete the last element from the Heap.
    3. Since, the last element is now placed at the position of the root node.
    4. So, it may not follow the heap property. Therefore, heapify the last node placed at the position of root.