GateAI
Trees

GATE CSE 2025 Set 2 · Q13

MCQ1 markEasy

Time

Consider a binary tree TT in which every node has either zero or two children. Let n>0n > 0 be the number of nodes in TT. Which ONE of the following is the number of nodes in TT that have exactly two children?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) (n - 1)/(2)

Trees

Let n0n_0 be the number of leaf nodes (nodes with 0 children), n1n_1 be the number of nodes with 1 child, and n2n_2 be the number of nodes with 2 children.

For any binary tree:

n0=n2+1n_0 = n_2 + 1

Since every node in TT has either zero or two children, n1=0n_1 = 0. The total number of nodes nn is:

n=n0+n1+n2=n0+n2n = n_0 + n_1 + n_2 = n_0 + n_2

Substitute n0=n2+1n_0 = n_2 + 1 into the total node equation:

n=(n2+1)+n2=2n2+1n = (n_2 + 1) + n_2 = 2n_2 + 1

Solving for n2n_2:

2n2=n−1  ⟹  n2=n−122n_2 = n - 1 \implies n_2 = \frac{n - 1}{2}

Thus, the number of nodes having exactly two children is n−12\frac{n-1}{2}, which corresponds to (B).

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 Q13 of the GATE CSE 2025 Set 2 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. 4 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2025 Set 2.

How GATE tests Trees

More from GATE CSE 2025 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 2 · Q13 · MCQ

Consider a binary tree T in which every node has either zero or two children. Let n > 0 be the number of nodes in T. Which ONE of the following is the number of nodes in T that have exactly two children?

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.