GATE / CS ARCHIVE

GATE CSE 2005 / QUESTION 36

Leaves in a full k-ary tree

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

GATE 2005, Q36 2 marks · MCQ
Report issue

Tree Properties & Traversals

Question 36, GATE 2005: A finite full k-ary tree has n internal nodes, each with exactly k children. Number of leaves? A nk; B(n−1)k+1; C n(k−1)+1; D n(k−1).
Question 36, GATE 2005: A finite full k-ary tree has n internal nodes, each with exactly k children. Number of leaves? A nk; B(n−1)k+1; C n(k−1)+1; D n(k−1).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

If there are n internal nodes and L leaves, the number of parent-child edges is kn. Any finite tree also has n+L−1 edges. Equating gives L=n(k−1)+1, C. The premise is that every internal node has exactly k children, not merely at most k.

Count the same edges in two ways. Every internal node contributes k outgoing parent-child edges, for kn. Any tree on n+L total nodes has n+L−1 edges. Equating and solving yields L=kn−n+1=n(k−1)+1. This method does not require every leaf to have the same depth; the exact-k-child premise is what matters.

Original paper, page 4