Which one of the following sequences when stored in an array at locations A[1], , A[10] forms a max-heap?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2023 · Q12
Time
Select one answerSingle correct
Solution
Official answer: B) 23, 17, 14, 7, 13, 10, 1, 5, 6, 12
Binary HeapsIn a 1-indexed binary max-heap stored in an array , the max-heap property requires that for every child at index (), its parent at index must satisfy:
Equivalently, for each parent index :
Left child is at index , so
Right child is at index , so
Let us check the given options:
Option A: For , , its left child is . Since (), the max-heap property is violated.
Option B: Checking all parent-child relationships:
: and
: and
: and
: and
:
All conditions are satisfied, so (B) is a valid max-heap.
Option C: For , , its child is . Since , it violates the max-heap property.
Option D: For , , its left child is . Since , it violates the max-heap property.
Try the question first, then check your work.
Examiner trap
In a 1-indexed array representation of a binary heap, the parent of index is at index . Check if holds for all .
This Binary Heaps previous year question is Q12 of the GATE CSE 2023 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 GATE CSE 2023 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.