A recursion tree visualizes the how a recurrence’s complexity is decreased for subproblems (see divide and conquer).

For the example, if the recurrence is

then we can build a recurrence tree like below, where each node represents the amount of work done at that node (in this case it’s , which is the subproblem size):

Note that the tree generally stops growing when all subproblems have ; this determines the height of the tree. For a simple case of , the tree height is . For more complex cases like the above, choose the largest in calculation.

With the recursion tree, we can sum across the row to obtain the number of primitive operations done at each level. We can turn it into a sequence, e.g. for the example above. Use the tree height (i.e. number of terms in the sequence) to obtain a sum, which is the closed-form expression for . So, having layers of , the above example yields .

Example

Now we can create a recursion tree (you can just visualize it since I didn’t want to make a diagram). Excluding the parent problem (work = ) we have:

Subproblem LayerWork done at layer
1
2

Now we know the work done at each layer is , we can multiply that by the number of layers (tree height) to get:

The log base of 3 can be ignored since it’s essentially a constant factor.