GateAI
Binary Heaps

GATE CSE 2026 Set 1 · Q23

MSQ1 markEasy

Time

Let nn be an odd number greater than 100. Consider a binary minheap with nn elements stored in an array PP whose index starts from 1. Which of the following indices of PP do/does NOT correspond to any leaf node of the minheap?

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: B) (n - 1)/(2); C) (n - 3)/(2)

Binary Heaps

In a 1-indexed complete binary tree (or binary heap) with nn elements:

  • The internal (non-leaf) nodes are located at indices 1,2,…,⌊n/2⌋1, 2, \dots, \lfloor n/2 \rfloor.

  • The leaf nodes are located at indices ⌊n/2⌋+1,…,n\lfloor n/2 \rfloor + 1, \dots, n.

Since nn is an odd number (n>100n > 100):

⌊n/2⌋=n−12\lfloor n/2 \rfloor = \frac{n-1}{2}

Thus:

  1. The internal nodes have indices from 11 up to n−12\frac{n-1}{2}.

  2. The leaf nodes have indices from n+12\frac{n+1}{2} up to nn.

Checking the given options:

  • (A) n+12\frac{n+1}{2}: This is the index of the very first leaf node.

  • (B) n−12\frac{n-1}{2}: This is the index of the last internal node, so it is not a leaf node.

  • (C) n−32\frac{n-3}{2}: Since n−32≤n−12\frac{n-3}{2} \le \frac{n-1}{2}, this is also an internal node and not a leaf node.

  • (D) nn: This is the index of the last leaf node.

Therefore, the indices that do NOT correspond to any leaf node are B and C.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Binary Heaps previous year question is Q23 of the GATE CSE 2026 Set 1 paper. Find more GATE CSE PYQs on Binary Heaps in Programming and Data Structures, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Binary Heaps in GATE CSE

Binary Heaps has 15 GATE CSE PYQs across 13 papers from 2011 to 2026. This is the only 1-mark MSQ among them, and it is the only one in GATE CSE 2026 Set 1.

How GATE tests Binary Heaps

More from GATE CSE 2026 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2026 Set 1 · Q23 · MSQ

Let n be an odd number greater than 100. Consider a binary minheap with n elements stored in an array P whose index starts from 1. Which of the following indices of P do/does NOT correspond to any leaf node of the minheap?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.