4.4 The recursion-tree method for solving recurrences
4.4-1
First let's create a recursion tree for the recurrence and assume that n is an exact power of 2.

Each level has three times more nodes than the level above, so the number of nodes at depth i is . And each node at depth i, for , has a cost of . So the total cost over all nodes at depth i, is . The bottom level, at depth , has nodes, each contributing cost , for a total cost of , which is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
But , so we need to try another guess. Let's try . So:
4.4-2
First let's create a recursion tree for the recurrence and assume that n is an exact power of 2.

The number of nodes at depth i is 1. And each node at depth i, for , has a cost of . So the total cost over all nodes at depth i, is . The bottom level, at depth , has 1 node, which contributing cost , for a total cost of , which is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
where the last step holds as long as .
4.4-3
When n is large, the difference between and not that large, so it's also a sloppiness that we can tolerate. Then let's create a recursion tree for the recurrence and assume that n is an exact power of 2.

Each level has four times more nodes than the level above, so the number of nodes at depth i is . And each node at depth i, for , has a cost of . So the total cost over all nodes at depth i, is . The bottom level, at depth , has nodes, each contributing cost , for a total cost of , which is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
But , so we need to try another guess, let's try . So:
where the last step holds as long as .
4.4-4
First let's create a recursion tree for the recurrence .

Each level has two times more nodes than the level above, so the number of nodes at depth i is . And each node at depth i, for , has a cost of 1. So the total cost over all nodes at depth i, is . The bottom level, at depth n, has nodes, each contributing cost , for a total cost of , which is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
But , so we need to try another guess. Lets try . So:
4.4-5
4.4-6
First let's create a recursion tree for the recurrence and assume that n is an exact power of 3.

Each level has 2 times more nodes than the level above, so the number of nodes at depth i is . But in this question, not all leaves reach at the bottom at the same time. The left most branch reaches the bottom first. So when the left most branch reaches the bottom, we assume other nodes also reach the bottom. Then the depth of recursion tree is .
The total cost over all nodes at depth i, is and the cost at bottom is also cn So:
But remember we've cut some branches of the recursion tree, so .
4.4-7
When n is large, the difference between and not that large, so it's also a sloppiness that we can tolerate. Then let's create a recursion tree for the recurrence and assume that n is an exact power of 2.

Each level has 4 times more nodes than the level above, so the number of nodes at depth i is . And each node at depth i, for , has a cost of . So the total cost over all nodes at depth i, is . The bottom level, at depth , has nodes, each contributing cost , for a total cost of , which is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
But , so let's try another guess, let's try .
where the last step holds as long as .
So . Then we want to show that for some constant . So:
where the last step holds as long as .
So , so .
4.4-8
First let's create a recursion tree for the recurrence and assume that n - 1 is divisible by a.

The total cost over all nodes at depth i, for , is . The bottom level, at depth , the total cost is , which is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
where the last step holds as long as and .
So .
Then we want to show that for some constant . So:
where the last step holds as long as .
So . So .
4.4-9
First let's create a recursion tree for the recurrence .

So we can see not each branch reaches at the bottom at the same time, it might be the left most branch reaches at the bottom first, or the right most branch reaches at the bottom first. It depends on which is smaller, or . Let , so we get . That is, when , the left most branch reaches at the bottom first, when , the right most branch reaches at the bottom first.
If , when the left most branch reaches at the bottom, let's assume other branches also reach at the bottom, so the total cost over all nodes at depth i, for , is cn. The cost at the bottom is also cn. So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
where the last step holds as long as .
Now let's check the right most branch. When it reaches at the bottom, other branches have already reached at the bottom, if the tree depth is k, let's assume other branches become T(1) at depth k - 1.
Each level has two times more nodes than the level above, so the number of nodes at depth i is . And total cost over all nodes at depth i, for , is cn. The cost at the bottom is . So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to veify that our guess was correct. We want to show that for some constant . So:
where the last step holds as long as .
So we proved and . So when .
Then let's check another case, when . In this case, the right most branch reaches at the bottom first. Let's assume other branches also reach at the bottom, so the total cost over all nodes at depth i, for , is cn. The cost at the bottom is cn. So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to verify that our guess was correct. We want to show that for some constant . So:
where the last step holds as long as .
Now let's check the left most branch. When it reaches at the bottom, other branches have already reached at the bottom, if the tree depth is k, let's assume other branches become T(1) at depth k - 1.
Each level has two times more nodes than the level above, so the number of nodes at depth i is . And total cost over all nodes at depth i, for , is cn. The cost at the bottom is T(1). So:
Thus, we have derived a guess of for our original recurrence. Now let's use the substitution method to veify that our guess was correct. We want to show that for some constant . So:
where the last step holds as long as .
So we proved and . So when . Thus for all .