Yep, the answer is ((1 - N^(h-1)) / ( 1 - N)) + M
where,
N: N-ary tree
h: Height of N-ary tree
M: No of leaf nodes
Example:
Suppose we are having 3-nary tree as shown below:
(h:1) (1)
(h:2) ((2) (3) (4))
(h:3) ((5) (6) (7)) ((8) (9) (10)) ((11) (12) (13))
(h:4) ((14) (15) (16)) ((17)) <-------- M (i.e. 4) Leaf Nodes
Here,
N: 3-ary tree
h: 4, Height of 3-ary tree
M: 4, No of leaf nodes
Now, Apply the formaula:
= ((1 - 3^(4-1)) / ( 1 - 3)) + 4
= 17
Hence Proved.
Solution by:
The Revolutions (Comp Sci RnD)
A Orkut's Community
http://www.orkut.com/Community.aspx?cmm=13552733
Yahoo Group
http://www.yahoogroups.com/group/TheRevolutions