The master theorem is a simple way to obtain an upper bound of the recurrence relation of a divide-and-conquer algorithm, assuming the ‘merging’ step takes polynomial time, and the ‘splitting’ is done with a constant fraction.
Formula
Master Theorem
Note
- = The amount of subproblems that are used by the algorithm (in the merging step)
- = The factor by which the main problem is divided into.
- = The polynomial factor of n, the additional work done by the algorithm in the merging step
- = The function representing the merge step
Can ?
Yes, actually! An algorithm can make use of a sub-solution multiple times, more than the splitting factor. One such example is in Strassen’s Algorithm, where and
Limitations
The Master Theorem, does however, have some limitations:
- Subproblem sizes must be exactly
- must be bounded polynomially
It does not work when:
- grows faster than any polynomial (e.g. )
- There are uneven splits or non-constant number of subproblems (e.g. )
- Subproblem sizes that are not fractions of
For such cases it is more useful to use Recursion Tree, substitution method (determine closed form + induction proof),#tosee Akra–Bazzi Theorem (generalization of Master Theorem)