Skip to content
Part IA Lent Term

Divide and Conquer

Overview

Divide and conquer is an algorithm design paradigm with three steps:

  1. Divide the problem into smaller subproblems of the same type.
  2. Conquer the subproblems by solving them recursively. If a subproblem is small enough, solve it directly (base case).
  3. Combine the solutions to the subproblems into a solution for the original problem.

The paradigm works best when subproblems are independent (no overlap) and the combine step is cheap relative to the recursive work.

Canonical Examples

AlgorithmDivideConquerCombine
MergesortSplit array into two halvesRecursively sort each halfMerge the two sorted halves (Θ(n)\Theta(n))
QuicksortPartition around a pivotRecursively sort left and right partitionsNothing (trivial concatenation)
Binary searchCompare with midpointRecurse on left or right halfNothing (answer propagated up)

Recurrence Relations

Divide-and-conquer algorithms naturally lead to recurrences of the form:

T(n)=aT ⁣(nb)+f(n)T(n) = a \cdot T\!\left(\frac{n}{b}\right) + f(n)

where aa subproblems of size n/bn/b are solved recursively, and f(n)f(n) is the cost of dividing and combining.

Solving Recurrences

Recurrences of the form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n) are solved using the Master Theorem, which has three cases based on comparing f(n)f(n) against nlogban^{\log_b a}. The detailed statement, worked examples, the recursion-tree method, and guidance on when the theorem does not apply are covered there.

When Divide-and-Conquer Works Well

  1. Subproblems are independent — no overlapping work.
  2. The division yields subproblems of roughly equal size (ratio splits, not constant-sized subproblems). Even a 25%-75% split yields Θ(nlogn)\Theta(n \log n) for quicksort.
  3. The combine step is efficient — ideally O(n)O(n) or less.

Warning: splitting off a constant-sized subproblem (e.g. T(n)=T(n1)+T(1)+Θ(n)T(n) = T(n-1) + T(1) + \Theta(n)) leads to Θ(n2)\Theta(n^2) behaviour. This is the degenerate case of quicksort with a bad pivot.

Summary

PropertyValue
ParadigmDivide, conquer, combine
Recurrence formT(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)
Solving toolMaster Theorem (3 cases)
Optimal splitEqual-sized subproblems
Worst splitConstant-sized subproblem leads to Θ(n2)\Theta(n^2)
Key examplesMergesort, quicksort, binary search, Strassen’s algorithm