in DS edited by
25,818 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$
in DS edited by
25.8k views

3 Comments

if 1-ary tree and 'i' is internal node then no of leave is 1

if 2-ary tree and 'i' is internal node then no of leaves are (i+1)

if 3-ary tree and 'i' is internal node then no of leaves are (2i+1)

if 4-ary tree and 'i' is internal node then no of leaves are (3i+1)

if n-ary tree and 'i' is internal node then no of leaves are (n-1)i+1

given that leaves L=41,internal node i=10,,

then L=(n-1)i+1

41=10n-10+1

10n=50

n=5
13
13

use two-equation 

N=L+i  ...(1)

N=M(i)+1... (2)

where n= total node in M-ary tree 

i= internal node 

 

2
2
No.of leaves (L)= (N-1)*INTERNAL NODE(I)+1

we find value of n.

41= (n-1)*10+1

= (n-1)*10=40

= n-1=4

n=5

 

SO answer will be option c
1
1

8 Answers

36 votes
36 votes
Best answer

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

2 Comments

total no. of nodes (t) = L(leaf node) + I (internal node)

t = 41 + 10

t= 51

edges (e) = t – 1

0* L + n*I = 51 -1

n*10 = 50

n = 5
2
2
Good question.
0
0
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$
by

3 Comments

great..
0
0

@arjun sir in this https://gateoverflow.in/3548/gate2006-it-9 u told that tree can be considered as directed graph and only outgoing edge can be considered as degree and leaf has a 0 degree then sum of degree = no of edges .In this why different 

0
0

@once_2019 i think this solution is question specific.

In tree degree of node means it's outgoing edges. right ?

0
0
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
by

2 Comments

same way.. i have done
1
1
reference?..............rosen?????
1
1
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