An array [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] is heapified. Which one of the following options represents the first three elements in the heapified array?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2024 Set 1 · Q41
Time
Select one answerSingle correct
Solution
Official answer: D) 131, 111, 90
Binary HeapsWe use the standard bottom-up max-heap construction algorithm (1-based indexing).
Initial array of size :
Heapify is called on non-leaf nodes from index down to :
():
Children: Left child .
Since , no swap needed.
():
Children: Left child , Right child .
Largest is . Swap and .
Array becomes: .
():
Children: Left child , Right child .
Since and , no swap needed.
():
Children: Left child , Right child .
Largest is . Swap and .
Heapify down at index : Children are . Since , no further swap.
Array becomes: .
():
Children: Left child , Right child .
Largest is . Swap and .
Heapify down at index : Children are . Largest is . Swap and .
Heapify down at index : Child is . Largest is . Swap and .
Array becomes: .
The first three elements of the heapified array are 131, 111, 90, which corresponds to Option (D).
Try the question first, then check your work.
Examiner trap
Apply standard bottom-up max-heapify starting from the last internal node index down to index .
This Binary Heaps previous year question is Q41 of the GATE CSE 2024 Set 1 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. 5 of them are 2-mark MCQs like this one, and GATE CSE 2024 Set 1 has 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.