Consider a binary min-heap containing 105 distinct elements. Let k be the index (in the underlying array) of the maximum element stored in the heap. The number of possible values of k is
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2024 Set 1 · Q43
Time
Select one answerSingle correct
Solution
Official answer: A) 53
Binary HeapsIn a binary min-heap, every parent node has a value smaller than or equal to the values of its children. Therefore, the maximum element cannot be an internal node (since an internal node must be smaller than its children) and must reside at one of the leaf nodes.
For a complete binary tree/heap with elements stored in an array using 1-based indexing:
The internal nodes are located at indices .
The leaf nodes are located at indices from to , which is from index to index .
The total number of leaf nodes is:
Since the maximum element can appear at any leaf position, the number of possible values for the index is 53.
Hence, (A) is the correct option.
Try the question first, then check your work.
Examiner trap
In a min-heap, the maximum element must be at one of the leaf nodes. Find the total count of leaf nodes in a heap with 105 elements.
This Binary Heaps previous year question is Q43 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.