PROJECTENGRAM

MASTER THEOREM

Master Theorem

Tags: #◇CCDSALG #◇Algorithms #◇Computer Science #◇Computational Complexity #◇Efficiency #◇Algorithm Design Paradigms #◇Recursion #◇Recursion and Iteration #◇Analysis of Algorithms #◇Data Structures #◇Time Complexity #◇Space Complexity


◇Overview

The Master Theorem provides a direct way to solve recurrences of the form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) without step-by-step expansion.

◇Key Concepts

Standard form: T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) Three cases based on comparing f(n)f(n) with nlog⁡ban^{\log_b a} Used to solve ◇Divide and Conquer recurrences quickly Cannot handle all recurrences (non-standard forms require other methods)

◇Details / Theory

Standard Form

The Master Theorem applies to recurrences of the form:
T(n)=aT(nb)+f(n)T(n) = aT\left(\frac{n}{b}\right) + f(n)

where:
a≥1a \geq 1 — number of subproblems in the recursion b>1b > 1 — factor by which the input size is reduced f(n)f(n) — cost of work done outside the recursive calls (divide + combine)

Critical Value

Compute nlog⁡ban^{\log_b a} — this represents the total work done by the leaves of the recursion tree.

The Three Cases

Case 1: If f(n)=O(nlog⁡ba−ϵ)f(n) = O(n^{\log_b a - \epsilon}) for some ϵ>0\epsilon > 0
T(n)=Θ(nlog⁡ba)T(n) = \Theta(n^{\log_b a})
→ The leaf-level work dominates. The recursion tree is bottom-heavy.

Case 2: If f(n)=Θ(nlog⁡ba)f(n) = \Theta(n^{\log_b a})
T(n)=Θ(nlog⁡balog⁡n)T(n) = \Theta(n^{\log_b a} \log n)
→ Work is evenly distributed across all levels of the tree.

Case 3: If f(n)=Ω(nlog⁡ba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon}) for some ϵ>0\epsilon > 0, and af(n/b)≤cf(n)af(n/b) \leq cf(n) for some c<1c < 1
T(n)=Θ(f(n))T(n) = \Theta(f(n))
→ The root-level work dominates. The recursion tree is top-heavy.

Worked Examples

Example 1: Merge Sort — T(n)=2T(n/2)+nT(n) = 2T(n/2) + n
a=2,b=2⇒nlog⁡22=n1=na = 2, b = 2 \Rightarrow n^{\log_2 2} = n^1 = n f(n)=n=Θ(nlog⁡ba)f(n) = n = \Theta(n^{\log_b a}) → Case 2 T(n)=Θ(nlog⁡n)T(n) = \Theta(n \log n)

Example 2: Binary Search — T(n)=T(n/2)+1T(n) = T(n/2) + 1
a=1,b=2⇒nlog⁡21=n0=1a = 1, b = 2 \Rightarrow n^{\log_2 1} = n^0 = 1 f(n)=1=Θ(1)=Θ(n0)f(n) = 1 = \Theta(1) = \Theta(n^0) → Case 2 T(n)=Θ(log⁡n)T(n) = \Theta(\log n)

Example 3: T(n)=4T(n/2)+nT(n) = 4T(n/2) + n
a=4,b=2⇒nlog⁡24=n2a = 4, b = 2 \Rightarrow n^{\log_2 4} = n^2 f(n)=n=O(n2−1)f(n) = n = O(n^{2-1}) → Case 1 T(n)=Θ(n2)T(n) = \Theta(n^2)

Limitations

The Master Theorem does not apply when:
f(n)f(n) is not polynomially comparable to nlog⁡ban^{\log_b a} (e.g., f(n)=nlog⁡nf(n) = n \log n in some edge cases) The recurrence is not in the standard form (e.g., T(n)=T(n−1)+nT(n) = T(n-1) + n) In these cases, use the ◇Recursion Tree Method or ◇Substitution Method

◇Common Pitfalls

Applying the Master Theorem to non-standard forms like T(n)=T(n−1)+nT(n) = T(n-1) + n — it only works for divide-type recurrences. Forgetting the regularity condition in Case 3: af(n/b)≤cf(n)af(n/b) \leq cf(n). Confusing which case applies — always compute nlog⁡ban^{\log_b a} first and compare.

◇Summary

TL;DR — The Master Theorem solves recurrences T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) by comparing f(n)f(n) to nlog⁡ban^{\log_b a} across three cases: leaf-heavy, balanced, or root-heavy.

Related: ◇Divide and Conquer — ◇Recursion Tree Method — ◇Substitution Method — ◇Asymptotic Notation — ◇Big-O Notation — ◇Big-Theta Notation Source / Reference: Handout 03

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

What is the primary purpose of the Master Theorem?

Q2

In the standard recurrence form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n), what does aa represent?

Q3

In the standard recurrence form, what does f(n)f(n) represent?

Q4

What is the critical value computed to determine which Master Theorem case applies?

Q5

In Case 1 of the Master Theorem, which part of the recursion tree dominates the work?

Q6

According to Case 2 of the Master Theorem, if f(n)=Θ(nlog⁡ba)f(n) = \Theta(n^{\log_b a}), what is T(n)T(n)?

Q7

What must be true for Case 3 of the Master Theorem to apply, besides f(n)f(n) being larger than the critical value?

Q8

For Merge Sort, T(n)=2T(n/2)+nT(n) = 2T(n/2) + n. Which case of the Master Theorem applies?

Q9

What is a key limitation of the Master Theorem?

Q10

If a recurrence does not fit the Master Theorem, which alternative method is recommended?