Sequences and Series Master theorem R. Inkulu http://www.iitg.ac.in/rinkulu/ (Asymptotic growth of functions) 1/8 Recurrence relations • useful in the analysis of recursive algorithms, primarily, in divide-and-conquer algorithms • R(n) = aR(n/b) + f (n): R(n) signifies the resources required to solve the problem when n objects are involved; f (n) signifies the resources involved in dividing n elements into n/b sized a numbered subproblems, and combining the solutions of these subproblems into one. (Asymptotic growth of functions) 2/8 Recurrence tree corresponding to a recurrence relation a f(n) f(n/b) f(n/b) f(n/b) a a a lg b n Θ (1) Θ (1) Θ (1) Θ (1) lg a n b T(n) = (Asymptotic growth of functions) ( Θ(1) if n = 1 aT(n/b) + f (n) if n > 1 3/8 Master theorem Let a ≥ 1 and b > 1 be constants, let f (n) be a function, and let T(n) be defined on the nonnegative integers by the recurrence T(n) = aT(n/b) + f (n) (with T(n) = Θ(1) when n = 1) where we interpret n/b to mean either ⌊n/b⌋ or ⌈n/b⌉. Then T(n) has the following asymptotic bounds: (i) If f (n) = O(nlgb a−ǫ ) for some constant ǫ > 0, then T(n) = Θ(nlgb a ). (ii) If f (n) = Θ(nlgb a ), then T(n) = Θ(nlgb a lg n). (iii) If f (n) = Ω(nlgb a+ǫ ) for some constant ǫ > 0, and if af (n/b) ≤ cf (n) for some constnat c < 1 and all sufficiently large n, then T(n) = Θ(f (n)). Do note that not every recurrence of the form T(n) = aT(n/b) + f (n) can be bounded using Master Theorem. (Asymptotic growth of functions) 4/8 Examples • T(n) = 9T(n/3) + n — case (i) leads to T(n) = Θ(n2 ) • T(n) = T(2n/3) + 1 — case (ii) leads to T(n) = Θ(lg (n)) • T(n) = 3T(n/4) + n lg n — case (iii) leads to T(n) = Θ(n lg n) • T(n) = 2T(n/2) + n lg n — Master thm not applicable (Asymptotic growth of functions) 5/8 Proof of the master theorem1 From the recurrence tree, T(n) = Θ(nlgb a ) + Plgb n−1 j=0 aj f ( bnj ) Then the second term of the RHS becomes Plgb n−1 j n lg a−ǫ • in case (i), O( j=0 a ( bj ) b ) = O(nlgb a ) • for the case (ii), Θ( • for the case (iii), ( further, ( Plgb n−1 j=0 Plgb n−1 j=0 Plgb n−1 j=0 aj ( bnj )lgb a ) = Θ(nlgb a lg n) cj f (n)) + O(1) = O(f (n)) aj f ( bnj )) ∈ Ω(f (n) 1 we prove for the case wherein n is an exact power of b > 1; proof of the general case is more or less the same (Asymptotic growth of functions) 6/8 Asymptotic bounds of typically occurring recurrences T(n) ≤ qT(n/2) + cn when n > 2, and T(2) ≤ c • If q = 1 then T(n) = Θ(n) • If q = 2 then T(n) = Θ(n lg n) • If q > 2 then T(n) = Θ(nlg2 q ) T(n) ≤ qT(n/2) + cn2 when n > 2, and T(2) ≤ c • If q < 4 then T(n) = Θ(n2 ) • If q = 4 then T(n) = Θ(n2 lg n) • If q > 4 then T(n) = Θ(nlg2 q ) (Asymptotic growth of functions) 7/8 Akra-Bazzi method — not presented (Asymptotic growth of functions) 8/8