Introduction
Divide and conquer solves a problem by splitting it into smaller instances of the same problem, solving those recursively, and combining their answers. Merge sort, quicksort and binary search are the familiar examples. This note states the paradigm, shows how its running time becomes a recurrence, and works through the other standard examples: the minimum and maximum together, fast exponentiation, the maximum subarray, and fast integer and matrix multiplication.
The pattern pays off when the combine step is cheap compared with solving the whole problem directly, or when the split lets us avoid work (binary search discards half; Strassen's method uses 7 recursive products instead of 8).
Prerequisites
- Solving Recurrences and the Master Theorem: every running time in this note is a recurrence solved by the master theorem or a recursion tree.
Core concepts
The three steps
- Divide the instance of size into subinstances, each of size about .
- Conquer each subinstance recursively; instances below a fixed size are solved directly (the base case).
- Combine the sub-answers into the answer for the whole instance.

The running-time recurrence
If dividing and combining together cost , the running time satisfies
The master theorem compares with , the number of leaves of the recursion tree. Two ways to make an algorithm faster follow directly: reduce (fewer recursive calls, as in Karatsuba and Strassen) or reduce (a cheaper combine).
| Algorithm | ||||
|---|---|---|---|---|
| Binary search | 1 | 2 | ||
| Fast exponentiation | 1 | 2 | multiplications | |
| Maximum and minimum | 2 | 2 | comparisons | comparisons ( a power of 2) |
| Merge sort | 2 | 2 | ||
| Maximum subarray | 2 | 2 | ||
| Karatsuba multiplication | 3 | 2 | ||
| Matrix product, 8 subproducts | 8 | 2 | ||
| Strassen | 7 | 2 |
For binary search, merge sort and quicksort see Searching, Merge Sort and Quicksort.
Algorithms and pseudocode
Pseudocode uses 1-based arrays, <- for assignment and A[i..j] for the subarray from position to position .
Maximum and minimum together
Finding the maximum alone needs comparisons, and the minimum alone another . Divide and conquer finds both with fewer:
MAX-MIN(A, i, j)
1 if i = j then
2 return (A[i], A[i])
3 if j = i + 1 then
4 if A[i] > A[j] then return (A[i], A[j])
5 else return (A[j], A[i])
6 mid <- floor((i + j) / 2)
7 (max1, min1) <- MAX-MIN(A, i, mid)
8 (max2, min2) <- MAX-MIN(A, mid + 1, j)
9 return (max(max1, max2), min(min1, min2)) // 2 comparisonsThe comparison count satisfies , and . For with (), the solution is exactly
Proof by unrolling: there are leaves of size 2 costing 1 each, and internal combines costing 2 each, so . This matches the lower bound for finding both, which is derived in Comparison of Sorting Algorithms. For not a power of 2 the halving version (left part elements, as floor((i + j) / 2) gives) can use more; the pairwise (non-recursive) method that compares elements in pairs always achieves .
| 5 | 6 | 7 | 8 | 10 | 12 | |
|---|---|---|---|---|---|---|
| MAX-MIN with halving | 6 | 8 | 9 | 10 | 14 | 18 |
| 6 | 7 | 9 | 10 | 13 | 16 |
The loss appears when a halving step creates two parts of odd size: for the split costs , while costs . A question that says " is a power of 2" avoids the issue; otherwise ask which split the code uses.

Fast exponentiation
POWER(x, n) // n >= 1
1 if n = 1 then
2 return x
3 y <- POWER(x, floor(n / 2))
4 y <- y * y
5 if n is odd then
6 y <- y * x
7 return yor , so multiplications instead of . Exactly, POWER uses squarings plus one extra multiplication for each 1 bit of except the leading one: multiplications, where is the number of 1 bits. For : multiplications ( from , from , from ).
Maximum subarray
Problem. Given with positive and negative values, find indices maximising .
Split at . The best subarray lies entirely in the left half, entirely in the right half, or crosses the midpoint. A crossing subarray is a best suffix of followed by a best prefix of , found in linear time:
FIND-MAX-CROSSING-SUBARRAY(A, low, mid, high)
1 left-sum <- -infinity; sum <- 0
2 for i <- mid downto low
3 sum <- sum + A[i]
4 if sum > left-sum then
5 left-sum <- sum; max-left <- i
6 right-sum <- -infinity; sum <- 0
7 for j <- mid + 1 to high
8 sum <- sum + A[j]
9 if sum > right-sum then
10 right-sum <- sum; max-right <- j
11 return (max-left, max-right, left-sum + right-sum)
FIND-MAXIMUM-SUBARRAY(A, low, high)
1 if high = low then
2 return (low, high, A[low])
3 mid <- floor((low + high) / 2)
4 (l1, h1, s1) <- FIND-MAXIMUM-SUBARRAY(A, low, mid)
5 (l2, h2, s2) <- FIND-MAXIMUM-SUBARRAY(A, mid + 1, high)
6 (l3, h3, s3) <- FIND-MAX-CROSSING-SUBARRAY(A, low, mid, high)
7 return the triple with the largest sum. With all entries negative, the answer is the single largest entry (the problem as stated requires a non-empty subarray).
Related material. Kadane's scan solves the same problem in by keeping the best sum ending at each position; it is dynamic programming, not divide and conquer, and is commonly presented together with this algorithm.
Karatsuba multiplication
To multiply two -digit numbers, write and . Then
which needs four half-size products and gives , no better than school multiplication. Karatsuba's observation is that the middle term equals , so three products suffice: .
Counting one-digit products, with gives : 9 for 4-digit numbers and 81 for 16-digit numbers, against and 256 for the four-product split (ignoring the extra digit that the sums may carry).
Example: with , , , : , , , middle term , and .
Strassen's matrix multiplication
Splitting matrices into four blocks gives 8 block products and . Strassen's method forms 7 block products from sums and differences of blocks, using 18 block additions and subtractions in total, so
The exact seven products are not needed for the running-time analysis here; the recurrence, the count 7 and the result are.
Worked examples
Maximum subarray on 16 elements
, , , .
- Left half : best subarray .
- Right half : best subarray .
- Crossing: suffix sums of the left half from down are , best at . Prefix sums of the right half from up are , best at . The crossing sum is for .
The answer is the largest of , and : .

Recognising when divide and conquer helps
| Recurrence | Master theorem case | Result |
|---|---|---|
| case 1 () | ||
| case 1 | ||
| case 1 | ||
| case 2 | ||
| case 2 | ||
| case 3 (regularity holds) |
The last row is a warning: when the combine step dominates, splitting gains nothing.
Important properties and observations
- Divide and conquer suits problems whose subproblems are independent. When the same subproblem recurs many times (Fibonacci, LCS), plain recursion repeats work exponentially and dynamic programming is the right tool.
- The recursion depth is for an even split, so the stack uses space unless the algorithm also needs work arrays (merge sort's buffer).
- Balanced splits matter: quicksort's worst case comes from a split of sizes and , not from the paradigm.
- Small base cases are often solved by a simpler method (insertion sort below about 16 elements) because recursion overhead dominates there; this changes constants, not the asymptotic bound.
Common misconceptions.
- "Divide and conquer is always faster." is , the same as the direct method; only reducing or helps.
- "Strassen is for any matrix size with no cost." The constant and the extra additions make it slower than the cubic method for small .
- "MAX-MIN by divide and conquer uses comparisons." That is the cost of two separate scans; divide and conquer uses for a power of 2.
GATE examination perspective
- COUNT THE COMPARISONS. For maximum and minimum, (power of 2, ) or in general (the pairwise method); halving code can use more when is not a power of 2 (8 for ); for maximum alone, .
- WRITE THE RECURRENCE FIRST. Identify , and from the code (number of recursive calls, how much smaller each is, work outside the calls), then apply the master theorem.
- NUMBER OF MULTIPLICATIONS. Fast exponentiation needs ; Strassen uses 7 block products, the naive split 8; Karatsuba 3 instead of 4.
- CROSSING CASE. In the maximum-subarray algorithm the crossing subarray must include both and .
Summary
Sources
- T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms, 3rd ed., MIT Press, 2009: Chapter 4, Section 4.1 (the maximum-subarray problem) and Section 4.2 (Strassen's algorithm for matrix multiplication); Section 9.1 (minimum and maximum).