The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
82 views
A 4-ary tree,i.e. each node has either 0 or 4 children tree has 20 leaf nodes. Then the total number of nodes in the tree are ____.
in DS by (327 points)
edited by | 82 views
0
I cannot imagine how a 4-ary tree with 20 leaves is possible.
0
Not possible, i guess there is something wrong with question.

If we try to calculate no of internal nodes

N= 4*I + 1 = I + 20

Internal nodes are coming as 6.33 which is not possible.

19 leaf nodes can be possible with 6 internal nodes in total 25 nodes.

2 Answers

0 votes

          /                      Root                               \                          |

        /                   /                  \                         \                         |

     N1                 N2                 N3                    N4                       N6 

/            \      /           \        /              \          /               \          /              \

1  2  3  4      5  6  7    8      9  10  11  12        13  14  15  16        17  18  19  20

from above scenario we can conclude that tree is not possible with given data...

by Loyal (8k points)
0 votes
L=(K-1)*i+1

k=4

L=20

i=(20-1)/3

total node = internal + leaf nodes

N=i+l

N=20+7
ago by (147 points)

Related questions

+1 vote
1 answer
2
0 votes
3 answers
5
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,807 questions
54,713 answers
189,262 comments
79,703 users