GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 2.9

Leaves in a full ternary tree

Discrete Mathematics · Trees & Connectivity · Full GATE CSE 2002 paper

GATE 2002, Q2.9 2 marks · MCQ
Report issue

Trees & Connectivity

Question 2.9, GATE 2002: A rooted tree has n nodes, each with either zero or three children. How many leaves does it have?
(A) n/2; (B) (n−1)/3; (C) (n−1)/2; (D) (2n+1)/3.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Count edges in two ways.

Step 2: Every vertex except the root has exactly one parent edge, so there are n−1 edges. Every internal node has three children, so there are 3I edges. Equating gives I=(n−1)/3. Subtracting internal nodes from all nodes gives leaves L=n−(n−1)/3=(2n+1)/3. For the smallest nontrivial case n=4, this correctly returns three leaves.

Conclusion: Let I be the internal-node count and L the leaves. Each internal node supplies 3 child edges, while a tree has n−1 edges, so 3I=n−1. Hence L=n−I=(2n+1)/3, D, for n admitting such a tree.

Original paper, page 4