0 votes 0 votes Is it possible to delete intermediate node/number in Heap? Not a root or last. DS data-structures binary-heap + – Shashank Chavan asked Dec 18, 2015 • recategorized Jul 6, 2022 by Lakshman Bhaiya Shashank Chavan 536 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes Yes you will have to traverse the entire heap in worst case and then delete it, then replace that position with the last element and then call Build-heap procedure. radha gogia answered Dec 26, 2015 • selected May 4, 2017 by Shashank Chavan radha gogia comment Share Follow See 1 comment See all 1 1 comment reply nitishsandhu commented Dec 27, 2015 reply Follow Share it could be simply exchange that element with A[heapsize], and then decrement heapsize by 1, now call max heapify on that element. im assuming max heap. complexity is O(logn) 0 votes 0 votes Please log in or register to add a comment.