Reputation: 1692
Is it correct that the number of nodes in a tree, given maximum branching factor b
and maximum depth d
is O(b^d)?
I'm practicing some backtracking
problems and trying to analyze the run time complexity of the solution, which traverses through all nodes in the "backtracking tree"
Upvotes: 0
Views: 1293
Reputation: 101
Yes, the maximum number of nodes will be b^d (b on first level, then b*b on level 2, etc d time), but the actual number of nodes may vary if the tree is not full. For maximum analysis of complexity that is a correct assumption however.
Upvotes: 1