Master theorem - Wikipedia, the free encyclopedia
In the analysis of algorithms, the master theorem provides a solution in asymptotic terms (using Big O notation) for recurrence relations of types that occur in the analysis of many divide and conquer algorithms.
Algorithms such as above can be represented as a recurrence relation . This recursive relation can be successively substituted into itself and expanded to obtain expression for total amount of work done.
Read full article from Master theorem - Wikipedia, the free encyclopedia
In the analysis of algorithms, the master theorem provides a solution in asymptotic terms (using Big O notation) for recurrence relations of types that occur in the analysis of many divide and conquer algorithms.
Algorithms such as above can be represented as a recurrence relation . This recursive relation can be successively substituted into itself and expanded to obtain expression for total amount of work done.
The master theorem concerns recurrence relations of the form:
In the application to the analysis of a recursive algorithm, the constants and function take on the following significance:
If where (using Big O notation)
then:
Example
If it is true, for some constant k ≥ 0, that:
- where
then:
Case 3:
If it is true that:
- where
and if it is also true that:
- for some constant and sufficiently large (often called the regularity condition)
then:
Example
So it follows from the third case of the master theorem:
Application to common algorithms
Algorithm | Recurrence Relationship | Run time | Comment |
---|---|---|---|
Binary search | Apply Master theorem case , where [3] | ||
Binary tree traversal | Apply Master theorem case where [3] | ||
Optimal Sorted Matrix Search | Apply Akra-Bazzi theorem for and to get | ||
Merge Sort | Apply Master theorem case , where |