Nodes, Children And Leaves

In a complete k k -ary tree, every internal node has exactly k k children. The number of leaves in such a tree with n n internal nodes is _________ \text{\_\_\_\_\_\_\_\_\_} .

n k nk n ( k 1 ) n(k-1) ( n 1 ) k + 1 (n-1)k + 1 n ( k 1 ) + 1 n(k-1) + 1

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Satyabrata Dash
Jul 8, 2016

Any node which has children is called internal node. So, In case of tree with more than one node, root node is also an internal node.

Now,let's solve the problem using binary tree. In case of binary tree,k =2. Suppose, binary tree has 7 internal nodes.

ROOT

/ \

N N

/ \ / \

N N N N

/ \ / \ / \ / \

L L L L L L L L

N=Internal Node L=Leaf

So, n = 7 and L=8

(I) nk = 7*2 = 14 wrong

(II) (n-1)k+1 = (7-1)*2+1 = 13 wrong

(III) n(k-1)+1 = 7 (2-1)+1 = 8 right*

(IV) n(k-1) = 7*(2-1) = 7 wrong

Cheers!!

Yes a bit more generalized

Satyabrata Dash - 4 years, 11 months ago

@Char Galvez You are in brilliant.org now you won't be lacking ideas. Go ahead.

Satyabrata Dash - 4 years, 11 months ago

Log in to reply

Until now, I still don`t know what to do. :(

Char Galvez - 4 years, 10 months ago

More generalized: every node has $k$ children, so there are $nk$ leaves. But this counts all $n$ nodes twice, and the one root, so we subtract that to obtain $nk - n - 1$, or $n(k-1) + 1$.

John Bowden - 4 years, 11 months ago

Can you help me? 😭 We have this Mathematical Investigation subject. It's either we make mathematical modeling or games related to math or make another formula. I came up with another divisibility rule for 9 but I don't know how to do it. Huhu. Help me please.

Char Galvez - 4 years, 11 months ago
Peter Macgregor
Jul 18, 2016

Like Satyabrata I 'solved' the problem by checking a binary tree and ticking the formula which worked. Now that we know this formula works for (at least two!) binary trees it would be nice to prove it for a l l all k k _ary trees! I found a simple proof by induction -

Let L ( n ) L(n) be the number of leaves on a complete k k _ary tree with n n internal nodes. Assume as our hypothesis that, for some number of internal nodes, r r

L ( r ) = r ( k 1 ) + 1 L(r)=r(k-1)+1

Now choose any leaf, convert it to an internal node and draw from it k k branches. This creates one more internal node, destroys one leaf and creates k k new leaves. So

L ( r + 1 ) = L ( r ) + k 1 = r ( k 1 ) + 1 + ( k 1 ) = ( r + 1 ) ( k 1 ) + 1 L(r+1)=L(r)+k-1=r(k-1)+1+(k-1)=(r+1)(k-1)+1

This has the same form as the induction hypothesis with r r replaced by r + 1 r+1 .

Note also that the hypothesis holds when r = 1 r=1 because a tree with one internal node (the root) has k k branches and k k leaves. And indeed our formula gives

L ( 1 ) = 1 ( k 1 ) + 1 = k L(1)=1(k-1)+1=k

Everything is now set up to complete the proof by invoking the principle of mathematical induction to get

L ( n ) = n ( k 1 ) + 1 \boxed{L(n)=n(k-1)+1}

as required.

Hey good solution man!!

Satyabrata Dash - 4 years, 11 months ago

Log in to reply

hey thanks

Peter Macgregor - 4 years, 11 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...