The master method is a recurrence-solving cookbook approach. Although it cannot handle all recurrences, it is quite useful for dealing with a large number of recurrences seen in practice. Assume there is a recurrence of the form:

*T*(*n*) = *aT*(*n*/*b*)+â(*n*)

where a and b are random constants, and â is a function of n. This recurrence would occur in the analysis of a recursive algorithm that separates huge inputs of size n into n/b sub-problems, solves the sub-problems recursively, and then recombines the results. Splitting the problem into sub-problems and recombining the solutions is â(*n*).

Index of Article (Click to Jump)

## Master Theorem

This theorem is used to support the master approach. Let a>=1 and b>1 be constants, â(n) be a function, and T(n) be a recurrence function defined on non-negative integers.

*T*(*n*) = *aT*(*n*/*b*) + â(*n*)

where n/b might be taken as either n/b or n/b. Then T(n) can be asymptotically confined as follows:

**Case 1:** T(n)=θ(n_{log}^{b}_{a}) if â(n)=O(n^{log}_{b}^{a}-ϵ) for some constant ϵ>0.

**Case 2:** T(n)=(n^{log}_{b}^{a}lg n) if â(n) = (n^{log}_{b}^{a})

**Case 3: **T(n)=(â(n)) if â(n)=Ω(nlog_{b}a+ϵ) for some constant ϵ>0 and aâ(n/b)≤câ(n) for some constant c<1 and all sufficiently big n.

Let’s take the time to attempt to comprehend what the master theorem states before applying it to specific situations. In each of the three cases, the function â(n) is compared to the function n^{log}_{b}^{a}. The greater of these two functions(â(n) & n^{log}_{b}^{a}), determines the solution to the recurrence. If the function n^{log}_{b}^{a} is the bigger, like in case 1, the answer will be T(n)=θ(â(n^{log}_{b}^{a}). If the function â(n) is greater, as in case 3, the answer will T(n)=θ(â(n)). If the two functions have the same size, as in case 2, we multiply by a logarithmic factor, yielding T(n)=θ(n^{log}_{b}^{a }lg n)=(â(n)lg n).

## Technicalities of Master Method

There are several technicalities that must be grasped in addition to intuition.

- In the first case, â(n) must be polynomially less than n
^{log}_{b}^{a}. That is, for some constant ϵ> 0, â(n) must be asymptotically less than n^{log}_{b}^{a}by a factor of nϵ. - In the third case, â(n) must not only be greater than n
^{log}_{b}^{a}, and it must also be polynomially bigger and meet the “regularity” criterion that aâ(n/b)≤câ(n). Most polynomially limited functions we’ll come across, satisfy this requirement.

It’s crucial to note that the three cases shown above don’t represent all of the options for â (n). When â(n) is less than n^{log}_{b}^{a} but not polynomially smaller, there is a gap between examples 1 and 2. When â(n) is bigger than n^{log}_{b}^{a} but not polynomially greater, there is a gap between cases 2 and 3. The master technique cannot be used to solve the recurrence if the function â(n) falls into one of these gaps, or if the regularity criterion in case 3 fails to hold.

## How To Use Master Method

To apply the master method, we simply decide which case of the master theorem applies (if any) and record the result.

### Example 1

Consider the following scenario:

We have a=9, b=3, â(n)=n for this recurrence, and consequently, n^{log}_{b}^{a}=n^{log}_{3}^{9}=θ(n^{2}). As â(n)=0(n^{log}_{3}^{9}-ϵ), where ϵ=1, we can use case 1 of the master theorem to determine that T(n)=θ(n^{2}).

### Example 2

Consider this:

n^{log}b^{a}=n^{log}_{3/2}^{1}=n^{0}=1, where a=1, b=3/2 and â(n)=1, as â(n)=θ(n^{log}_{b}^{a})=θ(1), Case 2 applies, and the solution to the recurrence is T(n)=θ(lg n).

### Example 3

In the event of a recurrence,

here, a=3, b=4, â(n)=n lg n, and n^{log}_{b}^{a}=n^{log}_{4}^{3}=0(n^{0.793}) are the values. Case 3 applies if we prove that the regularity criterion holds for â(n)=Ω(n^{log}_{4}^{3}+ϵ), where ϵ0.2. (n). For c=3/4, aâ(n/b)=3(n/4)lg(n/4)≤(3/4)n lg n=câ(n) for sufficiently big n. As a result, T(n)=θ(n lg n).