Back to the 2024 paper

Module 1: Introduction

20247m

What is the Master's Theorem? State the general form and the three cases of the theorem. Use it to solve the following recurrence relations:
(i) T(n)=2T(n/2)+nT(n) = 2T(n/2) + n
(ii) T(n)=3T(n/2)+n2T(n) = 3T(n/2) + n^2
(iii) T(n)=2T(n/2)+n/log⁡nT(n) = 2T(n/2) + n/\log n
Explain which case applies in each situation.

Worked SolutionAI Assisted

Master's Theorem — Statement & Applications

Theorem

For T(n)=aT(n/b)+f(n)T(n)=aT(n/b)+f(n), a≥1a\ge1, b>1b>1:
Let c=log⁡bac=\log_b a.

  • Case 1: f(n)=O(nc−ϵ)f(n)=O(n^{c-\epsilon}) → T(n)=Θ(nc)T(n)=\Theta(n^{c}) (leaf heavy).
  • Case 2: f(n)=Θ(nclog⁡kn)f(n)=\Theta(n^{c}\log^{k} n) → T(n)=Θ(nclog⁡k+1n)T(n)=\Theta(n^{c}\log^{k+1} n); with k=0k=0 → Θ(nclog⁡n)\Theta(n^{c}\log n) (balanced).
  • Case 3: f(n)=Ω(nc+ϵ)f(n)=\Omega(n^{c+\epsilon}) + regularity af(n/b)≤c′f(n)a f(n/b)\le c' f(n) → T(n)=Θ(f(n))T(n)=\Theta(f(n)) (root heavy).

(i) T(n)=2T(n/2)+nT(n)=2T(n/2)+n

  • c=log⁡22=1c=\log_2 2=1 → nc=nn^{c}=n, f(n)=n=Θ(nc)f(n)=n=\Theta(n^{c}) → Case 2 (k=0) → T(n)=Θ(nlog⁡n)T(n)=\Theta(n\log n) (Merge Sort).

(ii) T(n)=3T(n/2)+n2T(n)=3T(n/2)+n^2

  • c=log⁡23≈1.585c=\log_2 3 \approx1.585, nc=n1.585n^{c}=n^{1.585}, f(n)=n2=Ω(nc+ϵ)f(n)=n^2=\Omega(n^{c+\epsilon}) with ϵ≈0.415\epsilon\approx0.415.
  • Regularity: 3(n/2)2=3n2/4≤cf(n)3(n/2)^2=3n^2/4 \le c f(n) with c=3/4<1c=3/4<1 holds → Case 3 → T(n)=Θ(n2)T(n)=\Theta(n^2)
    Alternatively leaf vs root: root dominates.

(iii) T(n)=2T(n/2)+n/log⁡nT(n)=2T(n/2)+n/\log n

  • c=1c=1 → nc=nn^{c}=n, f(n)=n/log⁡n=Θ(nc/log⁡n)f(n)=n/\log n = \Theta(n^{c}/\log n).
  • This is not polynomially smaller (nc−ϵn^{c-\epsilon}) nor Θ(nc)\Theta(n^{c}); it is n/polylogn/\text{polylog} — gap between cases 1 and 2.
  • Master Theorem does NOT apply (fails polynomial gap condition). By recursion tree / Akra-Bazzi:
    T(n)=2T(n/2)+n/log⁡n  ⇒  T(n)=Θ(nlog⁡log⁡n) T(n)=2T(n/2)+n/\log n\;\Rightarrow\; T(n)=\Theta(n\log\log n)
    Proof sketch: T(n)=n∑i=0log⁡n−11/(log⁡n−i)=nHlog⁡n=n⋅Θ(log⁡log⁡n)T(n)=n\sum_{i=0}^{\log n -1} 1/(\log n -i)=n H_{\log n}=n\cdot\Theta(\log\log n).
  • If forced into extended Case 2 (k=−1k=-1), some extensions give Θ(nlog⁡log⁡n)\Theta(n\log\log n).

Summary: (i) Θ(nlog⁡n)\Theta(n\log n) Case2, (ii) Θ(n2)\Theta(n^2) Case3, (iii) Gap case — Θ(nlog⁡log⁡n)\Theta(n\log\log n), master not applicable in strict form.

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.