# Master Method for Solving Recurrence Relation

The master method works only for following type of recurrences or for recurrences that can be transformed to following type.

T(n) = aT(n/b) + f(n) where a >= 1 and b > 1

There are following three cases: **1.** If f(n) = O(n^{c}) where c < Log_{b}a then T(n) = Θ(n^{Log}_{b}^{a})

**2.** If f(n) = Θ(n^{c}) where c = Log_{b}a then T(n) = Θ(n^{c}Log n)

3 . If ?(?) = ?(? ???? ?+∈ )for some ∈> 0 , and if ?? ( ? ? ) ≤ ??(?) for some constant c < 1 ??? ??? ???????????? ????? ?. ?(?) = ?(?(?))

**How does this work?**

Master method is mainly derived from recurrence tree method. If we draw recurrence tree of T(n) = aT(n/b) + f(n), we can see that the work done at root is f(n) and work done at all leaves is Θ(n^{c}) where c is Log_{b}a. And the height of recurrence tree is Log_{b}n

In recurrence tree method, we calculate total work done. If the work done at leaves is polynomially more, then leaves are the dominant part, and our result becomes the work done at leaves (Case 1). If work done at leaves and root is asymptotically same, then our result becomes height multiplied by work done at any level (Case 2). If work done at root is asymptotically more, then our result becomes work done at root (Case 3).

example- In binary search T(n) = T(n/2) + Θ(1). It also falls in case 2 as c is 0 and Log_{b}a is also 0. So the solution is Θ(Logn)

#SolvingRecurrences #Analysis #Algorithm #MasterMethod #Probyto #ProbytoAI

Subscribe and follow us for latest news in Data Science and Machine learning and stay updated!

Facebook: https://facebook.com/probyto

Twitter: https://twitter.com/probyto

LinkedIn: https://linkedin.com/company/probyto

Instagram: https://instagram.com/probyto