in Algorithms retagged by
2,689 views
3 votes
3 votes
Where in a max-heap might the smallest element reside, assuming that all elements are distinct ?
in Algorithms retagged by
2.7k views

1 comment

Smallest element will be at the last level of the max heap.
0
0

4 Answers

1 vote
1 vote
Best answer
In a max heap the smallest element will be one of the leaf nodes.
T(n) = O(n) for finding the smallest element in a max heap.
selected by
0 votes
0 votes
smallest element will b at last level of the max heap
by

1 comment

Not necessarily at last level. Minimum element will be at the leaf node. Eg. consider this max heap 5,4,2,3.

Here 2 is at 2nd level.
2
2
0 votes
0 votes
The smallest element in a max-heap will be present at the last level of a max-heap whose index start from floor(n/2)+1, floor(n/2)+2 ...., n.
0 votes
0 votes
Smallest Element will be one of the leaf node.

Related questions