edited by
25,778 views
31 votes
31 votes

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

  1. $3$
  2. $4$
  3. $5$
  4. $6$
edited by

8 Answers

Best answer
36 votes
36 votes

If you do little bit experiments on no of leaves, Internal nodes, you will realize that they have equation like following :-

No of leaves $(L) = (n-1) *$ Internal Nodes $(I) + 1$

Here we need to find $n$.

Putting values

$41 = (n-1) * 10 + 1$
$\implies(n-1) * 10 = 40$
$\implies n-1 = 4$
$\implies n = 5$

So, answer is C.

edited by
43 votes
43 votes
Sum of degrees in tree $= L +  I \times (n+1) - 1 = 10n + 50 ($Each leaf node has degree 1 and all internal nodes have degree $k+1,$ except root which has degree $k)$

So, number of edges $= 5n + 25 ($Number of edges in a graph (hence applicable for tree also) is half the sum of degrees as each edge contribute $2$ to the sum of degrees)

In a tree with $n$ nodes we have $n-1$ edges, so with $41+10 = 51$ nodes, there must be $50$ edges.

So, $5n + 25 = 50$

$\implies 5n = 25$

$\implies n = 5$
18 votes
18 votes

Full m-ary tree means : Every internal node have exactly m children. Other way, each node has zero or m children only. 

Some of the full m-ary trees.

T1 (m=2) ,  T2 (m=3) , T3 (m=5)  are full but Tis not.

In this question, how they define complete means the full m-ary tree. We have n-ary tree and Internal nodes ( I ) = 10 , Leaf nodes ( L ) = 41

$n = L+ I \\ =>n = 51 \\ =>n*10+1 = 51 \\ =>n = 5$

edited by
10 votes
10 votes

Total number of internal nodes = $I=10$
Total number of leaf nodes = $L=41$

for a $n-ary$ tree, levels starts with $0$ and at each level there are $n^k$ nodes; where $k$ it the level number.

\[\begin{align*} \text{total number of nodes} - L &= I \\ \left( 1 + n^1 + n^2 + \dots + n^k \right) - L &= I \\ \left( 1 + n^1 + n^2 + \dots + n^k \right) - 41 &= 10 \\ \left(n^1 + n^2 + \dots + n^k \right) &= 50 \\ \frac{n(n^k-1)}{n-1} &= 50 \qquad \text{;on putting }n=5 \\ n^k &= 41\\ \end{align*}\]

where, $n^k$ represents number of nodes in last level i.e. leaf nodes, so on taking option C verifies it.

Hence, answer = option C

Answer:

Related questions

17 votes
17 votes
3 answers
3
33 votes
33 votes
4 answers
4