GateAI
Binary Heaps

GATE CSE 2025 Set 1 · Q35

NAT1 markEasy

Time

The height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node. Suppose a Min-Heap TT stores 32 keys. The height of TT is ____________. (Answer in integer)

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 5

Binary Heaps

A binary min-heap with nn elements is a complete binary tree.

The height hh (defined as the number of edges on the longest path from the root to any leaf) of a complete binary tree with nn nodes is given by:

h=⌊log⁡2n⌋h = \lfloor \log_2 n \rfloor

For n=32n = 32:

h=⌊log⁡232⌋=5h = \lfloor \log_2 32 \rfloor = 5

Alternatively, considering levels:

  • Level 0: 20=12^0 = 1 node

  • Level 1: 21=22^1 = 2 nodes

  • Level 2: 22=42^2 = 4 nodes

  • Level 3: 23=82^3 = 8 nodes

  • Level 4: 24=162^4 = 16 nodes

Total nodes up to level 4 = 1+2+4+8+16=311 + 2 + 4 + 8 + 16 = 31 nodes.

The 32nd32^{\text{nd}} node is located at level 5. Thus, the maximum path from the root to a leaf node consists of 5 edges.

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 Q35 of the GATE CSE 2025 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 NAT question among them, and it is the only one in GATE CSE 2025 Set 1.

How GATE tests Binary Heaps

More from GATE CSE 2025 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 1 · Q35 · NAT

The height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node. Suppose a Min-Heap T stores 32 keys. The height of T is … (Answer in integer)

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.