• edited by
39,940 views
51 51 votes

The number of leaf nodes in a rooted tree of n nodes, with each node having $0$ or $3$ children is:

  1. $\frac{n}{2}$
  2. $\frac{(n-1)}{3}$
  3. $\frac{(n-1)}{2}$
  4. $\frac{(2n+1)}{3}$

8 Answers

Best answer
77 77 votes

$L =$ leaf nodes

$I =$ internal nodes

$n =$ total nodes $= L + I$

In a tree no. of edges  $= n - 1$

All edges are produced by only internal nodes so, 

$k\times I = n-1\qquad \to(1)$   (for $k-ary$ tree, in this question $k = 3$)

$L + I = n\qquad \to (2)$

Here, given options are in terms of "n". So, eliminating $I$ from $(1)$ and $(2)$,

$L = ((k-1)n+1)/k$

you get $L = (2n+1)/3$

Answer is D.

• edited by
33 33 votes

A Different way to solve the same Question

Total no of nodes in rooted tree is n .And every node is going to have either 0 children or 3 children a/c to the question .

        

     Total no of nodes      Leaf Nodes      n/2      (n-1)/3      (n-1)/2      (2n+1)/3
n = 4 (figure 1) 3 2 1 3/2 3
n = 7 (figure 2) 5 7/2 2 3 5
n = 10 (figure 3) 7 5 3 9/2 7
n = 13 9 13/2 4 6 9
n = 16 11 8 5 15/2 11

Option D satisfy all the condition of the question .So option D is the answer .

18 18 votes

total number of nodes (n)  = internal nodes(i )  +  leaf nodes(L) 

total number of nodes (n) =  3 * nodes with three children (x)  + 1 

n = 3*x + 1 

x = (n-1)/3

n = i +L

L = n-i

L = n - (n-1)/3

L = (2n+1)/3

4 4 votes

We know no of leaf nodes(l) in a k-ary tree (l) = i(k-1)+1 (i represents internal nodes)

here k=3 so l=i(3-1)+1==>l=2i+1==>l-2i=1----------(a).

and we know total no of nodes in a tree (n) = Leaf nodes(l)+internal nodes(i)

so n=l+i;==>(b).

Add (a) & (b)

               (a)---->l-2i=1

          2*(b)---->2l+2i=2n

_________________________

3l=2n+1===> so l=(2n+1)/3;

0 0 votes
Any n-ary tree in which every node has either 0 or n children will take L=(n-1)*I +1
Given data n=3.
L=(3-1)I +1 =2I +1 -------> 1

 To find total number of nodes is nothing but sum of leaf nodes and internal nodes
N=L+I -------> 2
With the help of 1 and 2, we get L =(2n+1)/3.
0 0 votes
Another Approach -

$N$ = Total nodes
$L$ = Leaf nodes
$I$ = Internal nodes

No. of leaves of full n-ary tree(0 or n children) = $I\times(n-1)+1$

here, n=3

Also, $N=I+L$

Thus, $I=N-L$

$L=(N-L)\times(3-1)+1$

$L=2N-2L+1$

$3L=2N+1$

$L=\frac{2N+1}{3}$

 
Answer:
Position:
Show:

Related questions

154 154 votes
10 answers 10 answers
38.6k
38.6k views
Kathleen asked Sep 15, 2014
38,627 views
A weight-balanced tree is a binary tree in which for each node, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the rig...
47 47 votes
4 answers 4 answers
20.8k
20.8k views
Kathleen asked Sep 15, 2014
20,807 views
Consider the following $32\text{-bit}$ floating-point representation scheme as shown in the format below. A value is specified by $3$ fields, a one bit sign field (with $...
32 32 votes
5 answers 5 answers
16.3k
16.3k views
Kathleen asked Sep 15, 2014
16,312 views
A device employing INTR line for device interrupt puts the CALL instruction on the data bus while:$\overline{\text{INTA}}$ is activeHOLD is activeREADY is inactiveNone of...
30 30 votes
2 answers 2 answers
4.9k
4.9k views
Kathleen asked Sep 15, 2014
4,943 views
Draw all binary trees having exactly three nodes labeled $A, B$ and $C$ on which preorder traversal gives the sequence $C, B, A$.