Nice answer @adad20. Even if duplicate elements are present then also no issue.

Dark Mode

359 views

3 votes

Max element in min heap will present at leaf node.

Min heap has 2048 elements.

#leaf nodes = $\left \lceil 2048/2 \right \rceil$ = 1024

So in total min number of comparisons needed = 1024 – 1 = 1023

PS: Good thing to remember, In a binary heap of ‘n’ nodes there are exactly $\left \lceil n/2 \right \rceil$ leaf nodes.