Quantcast
Channel: Stories applauded for by Malay Nandasana on Medium
Viewing all articles
Browse latest Browse all 10

Master Theorem

$
0
0

Solve Recurrence Relation Using Master Theorem / Method

Not all the recurrences can be solved using the Master Theorem, but it still solves a large family of recurrences.

To solve a recurrence relation running time you can use many different techniques. One popular technique is to use the Master Theorem also known as the Master Method. “ 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.”-Wikipedia

The Master Method is used for solving the following types of recurrence

T (n) = a T (n/b) + f (n) with a≥1 and b≥1 be constant & f(n) be a function

Let T (n) is defined on non-negative integers by the recurrence.

  • n is the size of the problem.
  • a is the number of sub problems in the recursion.
  • n/b is the size of each sub problem. (Here it is assumed that all sub problems are essentially the same size.)
  • f (n) is the time to create the sub problems and combine their results in the above procedure
  • It is not possible always bound the function according to the requirement, so we make three cases which will tell us what kind of bound we can apply on the function.

There are following three cases:

Inadmissible equations:

Conclusion

A very important point worth noting is that, we need to apply this method only to recurrence which satisfy the necessary conditions. You can try applying it to more complicated recursions. The approach remains same.

References:
“Introduction to Algorithm” by Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein.

Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images