in this why we r not applying simply down heap function on that node which we wanna delete
Downheap use on delete element
Hi @Mukesh_1
Since deleting an element at any intermediary position in the heap can be costly, so we have to replace the element to be deleted by the last element and delete the last element of the Heap.
- Replace the root or element to be deleted by the last element.
- Delete the last element from the Heap.
- Since, the last element is now placed at the position of the root node. So, it may not follow the heap property. Therefore, heapify the last node placed at the position of root.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.