1,603 views
0 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 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
Position:
Show:

Related questions

0 0 votes
1 1 answer
972
972 views
Shubham Aggarwal asked Aug 29, 2018
972 views
4 4 votes
2 2 answers
172
172 views
GO Classes asked Jul 21
172 views
The following max-heap is stored using $1$-based indexing:$[57, 53, 42, 48, 25, 34, 29, 18, 30, 25]$Insert $55$ into this max-heap. What is the final heap array?$[57, 55,...
2 2 votes
1 answers 1 answer
947
947 views
Thor-o-s asked Sep 1, 2022
947 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 eleme...
0 0 votes
1 1 answer
1.6k
1.6k views
atulcse asked Jan 16, 2022
1,555 views
Consider the following graph:Find the total number of max-heap possible orderings with elements 12, 10, 1, 5, 7, 9, 8 such that each element is filled in one node of the ...