Skip to content
Official PYQ · 2005

GATE CS 2005 Q36 — Trees

Explain with AI

In a complete kk-ary tree, every internal node has exactly kk children. The number of leaves in such a tree with nn internal node is:

Choose one option
View worked solution

Answer: C

We can determine the number of leaves in a complete kk-ary tree by establishing a relationship between the total number of nodes, internal nodes, and leaves.

Let:

  • nn = number of internal nodes
  • LL = number of leaf nodes
  • NN = total number of nodes in the tree

By definition, the total number of nodes is the sum of internal nodes and leaf nodes:

N=n+L— (Equation 1)N = n + L \quad \text{--- (Equation 1)}

Since every internal node has exactly kk children, the total number of children in the tree is n×kn \times k. In any tree, every node except the root is a child of some node. Therefore, the total number of nodes is also given by:

N=n⋅k+1— (Equation 2)N = n \cdot k + 1 \quad \text{--- (Equation 2)}

Equating Equation 1 and Equation 2:

n+L=n⋅k+1n + L = n \cdot k + 1

Solving for LL:

L=n⋅k−n+1L = n \cdot k - n + 1 L=n(k−1)+1L = n(k - 1) + 1

Thus, the number of leaves is n(k−1)+1n(k-1) + 1, which corresponds to Option C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Trees questions