A complete n-ary tree is one in which every node has 0 or n sons. If x is the…
1998
A complete n-ary tree is one in which every node has 0 or n sons. If x is the number of internal nodes of a complete n-ary tree, the number of leaves in it is given by
- A.
x(n−1)+1
- B.
xn−1
- C.
xn+1
- D.
x(n+1)
Attempted by 167 students.
Show answer & explanation
Correct answer: A
Let x be the number of internal nodes and L be the number of leaves. The total number of nodes is x + L. Since every internal node has n children, the total number of edges is nx. In a tree, edges equal nodes minus one, so nx = (x + L) - 1. Solving for L yields L = x(n-1) + 1.
Let:
x = number of internal nodes
L = number of leaves
In a complete n-ary tree, every internal node has exactly n children.
Step 1: Total nodes
Total nodes= x+L
Step 2: Total edges
A tree with N nodes has N−1 edges, so:
edges=(x+L)−1
But each internal node contributes exactly n edges, so:
edges=nx
Equate both:
nx=x+L−1
Solve for L:
L=nx−x+1
L=x(n−1)+1
✅ Correct Answer: A. x(n−1)+1
A video solution is available for this question — log in and enroll to watch it.