Divide & Conquer Beyond Sorting
In short: divide and conquer isn't only for sorting. Split the input, solve each half recursively, then combine the two answers — and the combine step is where the whole technique either pays off or doesn't. It wins when the combine is cheap (two half-size streak searches plus one linear crossing sweep) or when a clever combine needs fewer recursive calls than the obvious split (Karatsuba's three multiplies instead of four). Write the recurrence before you write the code: if the combine costs as much as solving the problem directly, or the halves overlap, divide and conquer won't help.

Merge sort taught you the pattern: divide the input, conquer each piece recursively, combine the answers. Lesson 1 gave you the tool to price it: . This lesson uses the pattern on problems that have nothing to do with putting things in order, and uses the recurrence to predict, before you write a line, whether splitting will pay.
The rule of thumb from the master theorem: divide and conquer wins when the combine is cheaper than solving the whole problem directly, or when you can get away with fewer recursive calls than the obvious split needs.
Fewer calls: multiplying big numbers
Tunebox's royalty ledger multiplies very large integers. The schoolbook method multiplies every digit of one number by every digit of the other: n² single-digit multiplications for two n-digit numbers.
Divide and conquer splits each number into a high half and a low half, , and expands the product:
That is four half-size multiplications: , which is still . No gain. The trick, found by Karatsuba, is that the middle term can be had from one multiplication, reusing the other two:
Step through it on two 8-digit numbers. The array is the digits of x then y:
Three half-size multiplies instead of four. One saved multiply per level compounds into a smaller exponent.
Split both numbers at m = 4 digits. The high halves are 1234 and 8765. 16 cells.
The recurrence becomes . Three calls on halves, the leaves dominate, and the cost is . Count it:
At 64 digits it uses under a third of the schoolbook count. The sums can carry into an extra digit, which inflates the small cases, but look at the ratios: each doubling of the digits multiplies Karatsuba's count by about 3 and the schoolbook's by 4.
❓ Cross-question — "Does Python do this?" Yes. CPython's integer multiply switches to Karatsuba once both numbers are several hundred digits long. Below that, the schoolbook loop's lower overhead wins. The numbers for that trade-off come next.
Karatsuba does more additions and bookkeeping per level than the schoolbook loop,
so its real cost is roughly for some overhead c against
. At 1,000 digits that's c × 56,870 against 1,000,000:
overhead c |
Karatsuba | schoolbook | cheaper |
|---|---|---|---|
| 10 | 568,706 | 1,000,000 | Karatsuba |
| 17 | 966,800 | 1,000,000 | Karatsuba |
| 18 | 1,023,670 | 1,000,000 | schoolbook |
| 30 | 1,706,117 | 1,000,000 | schoolbook |
Karatsuba wins only while c is below about 17.6. A better exponent always wins
eventually, but the constant decides where "eventually" starts, which is why real
libraries switch methods at a threshold.