GATE / CS ARCHIVE

GATE CSE 2007 / QUESTION 43

Leaves and branching factor of a full n-ary tree

Data Structures · Tree Properties & Traversals · Full GATE CSE 2007 paper

GATE 2007, Q43 2 marks · MCQ
Report issue

Tree Properties & Traversals

Question 43, GATE 2007: Here a complete n-ary tree means each node has exactly n children or none. It has I=10 internal nodes and L=41 leaves. Find n.
Options:
(A) 3
(B) 4
(C) 5
(D) 6
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Approach. Count child edges once from the parent side and once using the identity edges=vertices−1 for a tree. Equating the counts eliminates the shape of the tree.

2. Derivation and interpretation. Count the edges in two ways. Each of the I internal nodes contributes exactly n child edges, while a tree with I+L vertices has I+L−1 edges. Thus nI=I+L−1 and n=(10+41−1)/10=5 (C). The question calls this complete, but explicitly defines the full n-ary property, which is all the calculation needs.

Original paper, page 10