Solutions to Algorithms Illustrated (Part 1 - Chapter 4 - The Master Method)
Reference
Standard Recurrence Format
-
Base case: is at most a constant for all sufficiently small .
-
General case: for larger values of n,
where,
- number of recursive calls (rate of subproblem proliferation)
- input size shrinkage factor
- exponent for the polynomial term of the combine step
Master Theorem
If is is defined by a standard recurrence, with parameters , , and , then
Problem 4.1
It asks which of the options is the best intepretation of in the Master Theorem.
Solution
- Option D: The rate at which the work-per-subproblem is shrinking (per level of recursion).
Problem 4.2
It asks for the smallest correct upper bound among the given options for the recurrence: .
Solution
-
, ,
-
, and since , by case 1 of the Master Theorem, .
Problem 4.3
It asks for the smallest correct upper bound among the given options for the recurrence: .
Solution
-
, ,
-
, and since , by case 2 of the Master Theorem, .
Problem 4.4
It asks for the smallest correct upper bound among the given options for the recurrence: .
Solution
-
, ,
-
, and since , by case 1 of the Master Theorem, .
Problem 4.5
It asks for the smallest correct upper bound among the given options for the recurrence: .
Solution
-
Based on the general case of the Standard Recurrence Format, we know that we can not apply Master Theorem to find solution to this recurrence relation.
-
However, we can use recursion tree to come up with an upper bound on the amount of work.
-
At each recursion level,
- No. of subproblems = 1
- Size of subproblem reduces by square root.
-
Hence, total work is bounded by the recursion depth.
-
Let's take the continuous case assumption,
- We can break such that , where is a real number and .
- Hence, is equal to the recursion depth.
- Hence, smallest upper bound is .
Another approach based on Master Theorem
-
Using change of variables,
- Let
- And
-
After substitution, the recurrence relation takes the following form,
- The above equation is in the Standard Recurrence Format with , and , hence we can apply Master Theorem on it.
- , hence, case 2 applies.
- Correct upper bound is: