A max-heap is a heap where the value of each parent is greater than or equal to the value of its children. Which of the following is a max-heap?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2011 · Q23
Time
Select one answerSingle correct
Solution
Official answer: B)
Binary HeapsA binary max-heap must satisfy two properties [1]:
Shape Property (Complete Binary Tree): All levels of the tree are completely filled except possibly the last level, which is filled strictly from left to right [1].
Max-Heap Property: The key/value stored in each node must be greater than or equal to the keys stored in its children () [1].
Let us evaluate the options:
(A) The tree is not a complete binary tree because the right child of node is missing a left child, but node has a left child on the next level, violating the complete binary tree structure [1].
(B) It is a complete binary tree where every level is fully filled, and for every node, the parent value is greater than or equal to its children:
and
and
and
Therefore, (B) is a valid max-heap [1].
(C) Node has a right child , where , violating the max-heap property.
(D) The root is , which has a right child (), violating the max-heap property.
Thus, (B) is the correct option.
Try the question first, then check your work.
Examiner trap
Check both the complete binary tree structural property and the max-heap order property () for every node.
This Binary Heaps previous year question is Q23 of the GATE CSE 2011 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 2011.
How GATE tests Binary HeapsIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.