Following relationship holds in any n-ary tree in which every node has either 0 or n children.
L = (n-1)*I + 1
Where L is the number of leaf nodes and I is the number of internal nodes.
The tree is n-ary tree. Assume it has T total nodes, which is sum of internal nodes (I) and leaf nodes (L). A tree with T total nodes will have (T – 1) edges or branches.
In other words, since the tree is n-ary tree, each internal node will have n branches contributing total of n*I internal branches. Therefore we have the following relations from the above explanations,
n*I = T – 1
L + I = T
From the above two equations, it is easy to prove that L = (n – 1) * I + 1.
Thanks to venki for providing the proof.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- GFact 22 | (2^x + 1 and Prime)
- GFact 23 | (Brocard’s problem)
- 10 Interesting Facts About Computers
- Interesting Facts about DBMS
- Can C++ reference member be declared without being initialized with declaration?
- Facts and Question related to Style of writing programs in C/C++
- Dilworth's Theorem
- Storage of integer and character values in C
- Vantieghems Theorem for Primality Test
- Cauchy's Mean Value Theorem
- Nesbitt's Inequality
- G-Fact 20 (Cayley's formula for Number of Labelled Trees)
- G-Fact 19 (Logical and Bitwise Not Operators on Boolean)
- fseek() vs rewind() in C
- G-Fact 15