Skip to main content

GATE CSE 2025Data Structures › Trees & Binary Search TreesVerified

GATE CSE 2025 PYQ: ​​​​Consider a binary tree T T T in which every node has either zero or two children. Let n > 0 n>0 n > 0 be…

​​​​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?
 
  1. A
    n−22\frac{n-2}{2}
  2. B
    n−12\frac{n-1}{2}
    Correct answer
  3. C
    n2\frac{n}{2}
  4. D
    n+12\frac{n+1}{2}

Answer

(B) n − 1 2 \frac{n-1}{2} 2 n − 1 ​

Approach

Use the standard structural identities for a full binary tree (every node has either 0 or 2 children): the number of leaves equals the number of internal (degree-2) nodes plus one, and these two classes together account for all n nodes. Solve the resulting linear equation for the number of degree-2 nodes in terms of n.

In a full binary tree, $n = 2I + 1$ where $I$ is the number of internal (two-child) nodes, giving $I = \frac{n-1}{2}$. Only option B matches this result, and all community answers agree.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.