in DS recategorized by
1,183 views
3 votes
3 votes

In a binary max heap containing $n$ numbers, the smallest element can be found in ______

  1. $O(n)$
  2. $O(\log _2 n)$
  3. $O(1)$
  4. $O(\log_2 \log_2 n)$
in DS recategorized by
1.2k views

3 Answers

1 vote
1 vote

In binary max heaps, smallest element will be present at leaves which resides from $\lceil\frac{n}{2}\rceil$ to $n$ location so we need to traverse at max $\frac{n}{2}$ elements which takes O(n)$

GATE 2006

Hence Option A) is correct

0 votes
0 votes
0 votes
0 votes

In a max heap, the smallest element is always present at a leaf node. So we need to check for all leaf nodes for the minimum value. Worst case complexity will be O(n)


 
by
Answer:

Related questions