Answers

Question and Answer:

  Home  Placement Assistance

⟩ An N-ary tree has N sub-nodes for each node, it has M non-leaf nodesFind the no of leaf nodes?

consider a N-ary tree with depth d

Total no of nodes in the tree, T=1+N+N^2+...+N^d= (1-N^(d+1))/(1-N) --(1)

No. of non leaf nodes, M=(1-N^d)/(1-N) ---(2)

No. of leaf nodes = T-M = N^d ---(3)

from eq (2), d= log(base N) [MN-M+1] ---(4)

Therefore, no of leaf nodes = N^d = MN-M+1

 202 views

More Questions for you: