3.7.2 · D1Algorithm Paradigms

Foundations — Divide and conquer — template, correctness, recurrence

1,941 words9 min readBack to topic

Before you can read a single line of the parent note, you need to own every symbol it throws at you. This page builds each one from the ground up: plain words → a picture → why the topic even needs it. Nothing is assumed.


1. What is ? — the size of the problem

The picture: imagine a row of boxes. Count them. That count is .

Figure — Divide and conquer — template, correctness, recurrence

2. Splitting: , , and

When we divide, two separate numbers describe the split. Do not confuse them.

Figure — Divide and conquer — template, correctness, recurrence

3. Recursion and the base case

You will meet full recursion machinery again in Mathematical Induction and see it powering Mergesort, Quicksort, and Binary Search.


4. The combine step and


5. — the running-time function

You will learn to actually solve such equations in Recurrence Relations.


6. — how many times you can halve

Concrete: with and : takes 3 steps, so .

Figure — Divide and conquer — template, correctness, recurrence

7. Exponents: , , and the watershed


8. , , — growth-rate shorthand


The prerequisite map

n = problem size

a pieces and b shrink

recursion + base case

combine and f of n

T of n recurrence

log base b of n = tree height

a to the i and leaf cost

watershed exponent log base b of a

Divide and Conquer analysis

Theta O Omega growth

Everything upstream feeds the two things the parent note actually does: prove correctness (via recursion = Mathematical Induction) and find speed (via the recurrence + Master Theorem, applied to Mergesort, Binary Search, Karatsuba, Strassen Matrix Multiplication, and contrasted with Dynamic Programming).


Equipment checklist

Test yourself — cover the right side and answer out loud.

What does measure?
The size of the input (e.g. number of items in the list).
What is ?
The number of subproblems you actually solve after splitting.
What is ?
The factor the input size shrinks by; each subproblem has size .
Why can ?
They count different things — is how much smaller each piece is, is how many pieces you recurse on (e.g. binary search has , ).
What is a base case and why is it required?
The smallest input, answered without recursion; it is the floor that stops the nesting so the program terminates.
What is ?
The non-recursive local work at one level: divide cost plus combine cost.
Read the recurrence in words.
The time for size equals copies of the time for size , plus the local divide-and-combine work.
What does equal, pictorially?
The number of times you divide by to reach — the height of the recursion tree.
What is ?
The watershed exponent; is the number of leaves (smallest boxes), the leaf cost you compare against.
What do , , mean?
Grows no faster than (ceiling), no slower than (floor), and exactly like (tight) the given function.
Recall Quick self-quiz

If and , how many levels does the recursion have? ::: . If and there are levels, how many leaves? ::: .