Let H be a binary min-heap consisting of n elements implemented as an array. What is the worst case time complexity of an optimal algorithm to find the maximum element in H?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2021 Set 2 · Q2
Time
Select one answerSingle correct
Solution
Official answer: C) (n)
Binary HeapsIn a binary min-heap:
The root element is always the minimum element in the heap.
By the min-heap property, every parent node has a value less than or equal to its children. Therefore, the maximum element cannot be an internal node with children; it must reside in one of the leaf nodes.
In a binary heap of elements implemented as an array, the leaves are stored from index to , which accounts for elements.
Since the leaf nodes are unordered relative to each other, finding the maximum element requires performing a linear scan over all leaf elements.
Thus, the worst-case time complexity is [cite: 1]. Hence, (C) is the correct option.
Try the question first, then check your work.
Examiner trap
In a min-heap, where can the maximum element possibly reside? Consider how many leaf nodes exist in a heap of size .
This Binary Heaps previous year question is Q2 of the GATE CSE 2021 Set 2 paper. Find more GATE CSE PYQs on Binary Heaps in Programming and Data Structures, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Binary Heaps PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Binary Heaps has 15 GATE CSE PYQs across 13 papers from 2011 to 2026. 6 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2021 Set 2.
How GATE tests Binary HeapsIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.