GateAI
Trees

GATE CSE 2015 Set 3 · Q25

NAT1 markEasy

Time

Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T that have exactly two children are _____.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 199

Trees

In any binary tree TT, let:

  • n0n_0 = number of leaf nodes (nodes with degree 0 / no children)

  • n1n_1 = number of nodes with exactly 1 child

  • n2n_2 = number of nodes with exactly 2 children

The total number of nodes is n=n0+n1+n2n = n_0 + n_1 + n_2.

The total number of edges in any tree with nn nodes is E=n−1E = n - 1.

Counting edges by outgoing degree of nodes:

E=0⋅n0+1⋅n1+2⋅n2=n1+2n2E = 0 \cdot n_0 + 1 \cdot n_1 + 2 \cdot n_2 = n_1 + 2n_2

Equating the two expressions for EE:

n0+n1+n2−1=n1+2n2  ⟹  n2=n0−1n_0 + n_1 + n_2 - 1 = n_1 + 2n_2 \implies n_2 = n_0 - 1

Given n0=200n_0 = 200:

n2=200−1=199n_2 = 200 - 1 = 199

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 Trees previous year question is Q25 of the GATE CSE 2015 Set 3 paper. Find more GATE CSE PYQs on Trees 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 Trees 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.

Trees in GATE CSE

Trees has 13 GATE CSE PYQs across 11 papers from 2012 to 2026. 5 of them are 1-mark NAT questions like this one, and it is the only one in GATE CSE 2015 Set 3.

How GATE tests Trees

More from GATE CSE 2015 Set 3

Share this solution

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

GateAI solution cardGATE CSE 2015 Set 3 · Q25 · NAT

Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T that have exactly two children are …

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.