Find the branching factor in a tree given the total number of nodes in the tree

353 Views Asked by At

Suppose I know the number of total employees and the number of levels in the company hierarchy.

Assuming that the number of subordinates a supervisor has is constant across the levels, how can I find the average number of subordinates per manager (branching factor) the company has?

1

There are 1 best solutions below

0
On BEST ANSWER

Say there are $n$ nodes. Then it can be anywhere between $n - 1$ (a root and $n - 1$ children) and $1$ (just a path of $n$ nodes).

You can argue similarly for several levels. Say you have exactly $k$ levels, that means a root (1), with $c$ children, each of those has $c$ children in turn ($c^2$ in all), ..., at level $k - 1$ there are $c^{k - 1}$ nodes in all. Thus:

$\begin{align*} 1 + c + c^2 + \dotsm + c^{k - 1} &= n \\ \frac{c^k - 1}{c - 1} &= n \\ c^k - 1 &= n (c - 1) \end{align*}$

This you'll have to solve numerically.