| Home / Mainframe - DB2 / A full N-ary tree has M non-leaf nodes, how many leaf nodes does it have? |
A full N-ary tree has M non-leaf nodes, how many leaf nodes does it have? |
||||
Use Geometric progression.
Here (N ^ (n-1)) is the number of leaf-nodes. Solving for this leads to the answer Leaf nodes = M * (N - 1) + 1
Suppose you have a 3-ary tree
So, here M=4 and N=3. So using the formula above,
|
||||
Powered by
KBPublisher (Knowledge base software)
