GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 10

Finding the minimum in a max heap

Data Structures · Heaps & Priority Queues · Full GATE CSE 2006 paper

GATE 2006, Q10 1 mark · MCQ
Report issue

Heaps & Priority Queues

Question 10, GATE 2006: What is the worst-case asymptotic time for finding the smallest of n numbers stored in a binary max-heap?
Options:
(A) Θ(n)
(B) Θ(log n)
(C) Θ(log log n)
(D) Θ(1)
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. A minimum occurs among the leaves. There are Θ(n) leaves and their values have no guaranteed mutual ordering.

2. Scanning them gives O(n) time; arbitrary leaf values require Ω(n) comparisons in the worst case. Therefore Θ(n), A.

3. Teaching check: A max-heap constrains each parent to be at least its children, so following children can only decrease values. Every internal node has some leaf descendant no larger than itself. However the roughly n/2 leaves have no ordering among themselves, so binary-search reasoning does not apply.

Original paper, page 2