In this post, I would like to share my knowledge of the Master Method also called as the Master Theorem. By no means I am a pure computer scientist so do not expect me to be cent percent correct and thorough.
Anyways, Let's get started.
So, a general recurrence relation (for which I'll describe my version of Master Method) is:
T(n) = a * T(n / b) + O(n^d)
Here, O(x) stands for BIG OH of x!
and "a" is the number of sub problems, "b" is the extent to which the bigger problem is divided into sub problems and "d" is the exponent of "n".
now for this to be a valid recurrence, we should have a >= 1, b >1 and d can be any integer >= 0
Now three cases arise, based on the comparison of " a" and "b^d"
Till then sayonara!
Anyways, Let's get started.
MASTER METHOD (MASTER THEOREM)First a bit about it. Master Method is a method (surprise!huh!) which can be used to get an upper bound on the time complexity of a problem. There are a few constraints though:
- The Problem should be a divide and conquer problem.
- Since it is a divide and conquer problem, It must be expressed as a recurrence.
- Dividing the problems into numerous sub problems (which are like the version of big problem but smaller in size).
- Conquer the sub problems (solve the sub problems).
- Solve the bigger problem by combining the solution of the smaller sub problems.
So, a general recurrence relation (for which I'll describe my version of Master Method) is:
T(n) = a * T(n / b) + O(n^d)
Here, O(x) stands for BIG OH of x!
and "a" is the number of sub problems, "b" is the extent to which the bigger problem is divided into sub problems and "d" is the exponent of "n".
now for this to be a valid recurrence, we should have a >= 1, b >1 and d can be any integer >= 0
Now three cases arise, based on the comparison of " a" and "b^d"
- If a = b^d then, the complexity is O(n^d log(n) )
- If a < b^d then, the complexity is O(n^d)
- If a > b^d then, the complexity is O(n^(log(a) to base b))
Till then sayonara!