Skip to content
Official PYQ · 2007

GATE CS 2007 Q43 — Trees

Explain with AI

A complete n−aryn-ary tree is a tree in which each node has nn children or no children. Let II be the number of internal nodes and LL be the number of leaves in a complete n−aryn-ary tree. If L=41L = 41 and I=10I = 10, what is the value of nn?

Choose one option
View worked solution

Answer: C

To find the value of nn, we can establish a relationship between the number of internal nodes (II), the number of leaves (LL), and the degree of the tree (nn).

Let NN be the total number of nodes in the nn-ary tree. By definition, we have:

N=I+LN = I + L

In a complete nn-ary tree, every internal node has exactly nn children, and the root is the only node that is not a child of any node. Therefore, the total number of nodes can also be expressed in terms of the children of internal nodes:

N=n⋅I+1N = n \cdot I + 1

Equating the two expressions for NN:

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

Rearranging the equation to solve for LL:

L=I(n−1)+1L = I(n - 1) + 1

Given that L=41L = 41 and I=10I = 10, we substitute these values into the equation:

41=10(n−1)+141 = 10(n - 1) + 1 40=10(n−1)40 = 10(n - 1) 4=n−14 = n - 1 n=5n = 5

Thus, the value of nn is 55, which corresponds to option C.

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

Published
Report a correction
Keep exploringMore Trees questions