Back to the 2022 paper

Module 1: Introduction

20227m

Solve the following recurrence by successive substitution method:
f(1)=1if n=1f(1) = 1 \quad \text{if } n=1
f(n)=3f(n/2)+6if n>1f(n) = 3f(n/2) + 6 \quad \text{if } n > 1

Worked SolutionAI Assisted

Solution – Recurrence f(n)=3f(n/2)+6f(n)=3f(n/2)+6, f(1)=1f(1)=1 by Successive Substitution

Assume n=2kn=2^k (k=log⁡2nk=\log_2 n).

Unfold:
f(n)=3f(n/2)+6=3[3f(n/4)+6]+6=32f(n/22)+6⋅3+6=32[3f(n/23)+6]+6⋅3+6=33f(n/23)+6⋅32+6⋅3+6  ⋮f(n)=3kf(n/2k)+6∑i=0k−13i \begin{aligned} f(n) &= 3f(n/2)+6 \\ &= 3[3f(n/4)+6]+6 = 3^2 f(n/2^2)+6\cdot3+6 \\ &= 3^2[3f(n/2^3)+6]+6\cdot3+6 = 3^3 f(n/2^3)+6\cdot3^2+6\cdot3+6\\ &\;\vdots \\ f(n) &= 3^k f(n/2^k)+6\sum_{i=0}^{k-1}3^i \end{aligned}

Since n/2k=1n/2^k=1, f(n/2k)=f(1)=1f(n/2^k)=f(1)=1 and ∑i=0k−13i=(3k−1)/(3−1)=(3k−1)/2\sum_{i=0}^{k-1}3^i = (3^k-1)/(3-1)=(3^k-1)/2.

f(n)=3k⋅1+6⋅3k−12=3k+3(3k−1)=4⋅3k−3 f(n)=3^k \cdot 1 +6\cdot\frac{3^k-1}{2}=3^k+3(3^k-1)=4\cdot3^k-3

With k=log⁡2nk=\log_2 n:
f(n)=4⋅3log⁡2n−3=4⋅nlog⁡23−3\boxed{f(n)=4\cdot 3^{\log_2 n}-3 = 4\cdot n^{\log_2 3}-3} for nn power of 2.

Asymptotics:
f(n)=Θ(nlog⁡23)=Θ(n1.58496…)f(n)=\Theta(n^{\log_2 3}) = \Theta(n^{1.58496\dots})

Check by Master Theorem: a=3a=3, b=2b=2, nlog⁡ba=nlog⁡23n^{\log_b a}=n^{\log_2 3} dominates f(n)=Θ(1)f(n)=\Theta(1) case 1 → Θ(nlog⁡23)\Theta(n^{\log_2 3}) consistent.

For general nn (not power of 2), embed between powers of 2 → same Θ\Theta.

Similar questions

Free AppAndroid App

Coursify Android App

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