Back to the 2023 paper

Module 1: Introduction

20235m

Apply the Master Theorem to determine the time complexity of the following recurrence relations.
(i) T(n)=4T(n/2)+n3T(n) = 4T(n/2) + n^3
(ii) T(n)=T(n/2)+2nT(n) = T(n/2) + 2^n

Worked SolutionAI Assisted

Master Theorem Applications

General Form: T(n)=aT(n/b)+f(n)T(n)=aT(n/b)+f(n), a≥1a\ge1, b>1b>1, f(n)f(n) asymptotically positive.
Let nlog⁡ban^{\log_b a} be the watershed.

  • Case 1: f(n)=O(nlog⁡ba−ϵ)f(n)=O(n^{\log_b a -\epsilon}) for ϵ>0\epsilon>0 → T(n)=Θ(nlog⁡ba)T(n)=\Theta(n^{\log_b a}).
  • Case 2: f(n)=Θ(nlog⁡balog⁡kn)f(n)=\Theta(n^{\log_b a}\log^k n) → T(n)=Θ(nlog⁡balog⁡k+1n)T(n)=\Theta(n^{\log_b a}\log^{k+1} n); special k=0k=0: Θ(nlog⁡balog⁡n)\Theta(n^{\log_b a}\log n).
  • Case 3: f(n)=Ω(nlog⁡ba+ϵ)f(n)=\Omega(n^{\log_b a+\epsilon}) and regularity af(n/b)≤cf(n)a f(n/b)\le c f(n) for c<1c<1 → T(n)=Θ(f(n))T(n)=\Theta(f(n)).

(i) T(n)=4T(n/2)+n3T(n)=4T(n/2)+n^3

  • a=4a=4, b=2b=2 → nlog⁡ba=nlog⁡24=n2n^{\log_b a}=n^{\log_2 4}=n^2.
  • f(n)=n3=Ω(n2+1)f(n)=n^3=\Omega(n^{2+1}) with ϵ=1\epsilon=1.
  • Regularity: 4(n/2)3=4n3/8=n3/2≤cn34(n/2)^3 =4 n^3/8 = n^3/2 \le c n^3 with c=1/2<1c=1/2<1 ✓
  • Case 3 → T(n)=Θ(f(n))=Θ(n3)T(n)=\Theta(f(n))=\Theta(n^3)

(ii) T(n)=T(n/2)+2nT(n)=T(n/2)+2^n

  • a=1a=1, b=2b=2 → nlog⁡ba=n0=1n^{\log_b a}=n^0=1.
  • f(n)=2nf(n)=2^n is exponential, not polynomial; 2n=Ω(nϵ)2^n = \Omega(n^{\epsilon}) for any ϵ\epsilon, dominated by ff.
  • Although f(n)=2n=Ω(n0+ϵ)f(n)=2^n = \Omega(n^{0+\epsilon}), regularity holds: 1⋅2n/2≤c2n1\cdot2^{n/2} \le c 2^n for large nn (c=1/2c=1/2) as 2n/2/2n=2−n/2→02^{n/2}/2^n=2^{-n/2}\to0.
  • This fits Case 3 (generalized interpretation) where ff dominates polynomially. Hence T(n)=Θ(f(n))=Θ(2n)T(n)=\Theta(f(n))=\Theta(2^n)

Note: Strict Master theorem in many textbooks requires ff polynomial; for exponential ff, the theorem still yields T(n)=Θ(2n)T(n)=\Theta(2^n) because nlog⁡ba=O(f(n))n^{\log_b a}=O(f(n)) and regularity holds; formally the answer is exponential dominated, not Θ(1)\Theta(1). Some state "Master theorem not applicable (f not polynomial)" but via extension the bound is Θ(2n)\Theta(2^n); if insisting on polynomial ff condition, declare not applicable, recurrence solves to Θ(2n)\Theta(2^n) by recursion tree: T(n)=2n+2n/2+2n/4+⋯+1=Θ(2n)T(n)=2^n+2^{n/2}+2^{n/4}+\dots+1 =\Theta(2^n).

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.