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
GATE CSE 2025 Set 2 · Q13
Time
Select one answerSingle correct
Solution
Official answer: B) (n - 1)/(2)
TreesLet be the number of leaf nodes (nodes with 0 children), be the number of nodes with 1 child, and be the number of nodes with 2 children.
For any binary tree:
Since every node in has either zero or two children, . The total number of nodes is:
Substitute into the total node equation:
Solving for :
Thus, the number of nodes having exactly two children is , which corresponds to (B).
Try the question first, then check your work.
Examiner trap
In any binary tree, the number of leaf nodes is related to the number of nodes with two children by . Express the total number of nodes in terms of .
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
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.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
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 TreesIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.