Question

Let nn be an odd number greater than 100100. Consider a binary minheap with nn elements stored in an array PP whose index starts from 11.

Which of the following indices of PP do/does NOT correspond to any leaf node of the minheap?

Choose every correct option
Official answer and solution
Official answer
B and C
From
Official GATE 2026 answer key

Solution

Use the 1-indexed binary heap property that internal (non-leaf) nodes occupy indices 11 through ⌊n/2⌋\lfloor n/2 \rfloor.

In a 1-indexed binary heap with nn elements, node ii has left child 2i2i and right child 2i+12i + 1. Thus node ii is a non-leaf (internal) node if and only if 2i≤n2i \le n, i.e., 1≤i≤⌊n/2⌋1 \le i \le \lfloor n/2 \rfloor, while leaf nodes occupy indices ⌊n/2⌋+1\lfloor n/2 \rfloor + 1 through nn.

Since n>100n > 100 is odd, ⌊n/2⌋=n−12\lfloor n/2 \rfloor = \frac{n-1}{2}. Therefore:

  • n−12\frac{n-1}{2} and n−32\frac{n-3}{2} are ≤n−12\le \frac{n-1}{2}, so they correspond to non-leaf nodes.
  • n+12\frac{n+1}{2} and nn are >n−12> \frac{n-1}{2}, so they correspond to leaf nodes.
Final answer

Options (B), (C)

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
Question
23 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.