Where the Substitution Method would prove that the solution to a recurrence is correct, a recursion tree would help us coming up with a good guess for the runtime page=144
Main Idea
Given a Recurrence Equations, .
- a is the number of branches
- b is how large those branches are
- f(n) is the merge cost (for example )
- The height of the tree, k, is given by
The height of the tree, k, is the same as .
We divide (branch out) and conquer (sort the arrays) before we merge them again.
If we encounter recurrences with square roots, we do this trick: Given Trick Then We can then use Master-theorem on S(M) → → , where
Examples
We want the height of the tree in this task, and only tells us about the cost of merging