682 views
0 votes
0 votes

Let's say we're given with a MAX Heap and we want to delete any of the leaf node, then how much time will it take to delete any of the leaf node and maintain the max heap property?

My main doubt is - will it O(n) time to reach to leaf nodes?

1 Answer

Best answer
3 votes
3 votes
Heap is nothing but an array with heap property. So If you wish to delete just $any$ leaf node, then Just delete the last element of the Heap and it will take just $O(1)$ time since It is an array and you can go to the last element in $O(1)$ time.
selected by

Related questions

0 votes
0 votes
1 answer
1
Shubham Aggarwal asked Aug 29, 2018
356 views
2 votes
2 votes
1 answer
2
Thor-o-s asked Sep 1, 2022
391 views
Can anyone please explain how to find “ i “ smallest elements from an array whose elements are distinctPlease use max heap to explain the working input : n distinct e...
0 votes
0 votes
1 answer
3