Divide-and-conquer algorithm Created 2026-10-13 Updated 2026-10-18
A divide-and-conquer algorithm divides a problem into smaller instances, solves them using recursion, and combines their answers. In merge sort, the division makes two contiguous halves, and the merge algorithm combines the resulting sorted arrays. The important design step is finding a combination rule cheaper than solving the whole problem afresh.
Halving the input is only one part of the design. The number of recursive calls and the work outside those calls determine whether the smaller instances actually save time. Divide-and-conquer combination cost keeps these quantities separate; the divide-and-conquer product ledger shows how an algebraic identity changes the number of required calls in Karatsuba multiplication.
For algorithm correctness, specify the meaning of each returned answer, prove the base cases, and show that combining correct smaller answers gives the required output. Induction then proves correctness, provided every recursive call progresses towards a base case. The combination rule must reconstruct everything the caller needs: two sorted halves alone are not a sorted array, and four digit blocks alone are not their integer product.
Divide-and-conquer product ledger 2026-10-18
Splitting two integers in positional notation gives and , where shifts a block by numeral digits in fixed radix . The distributive property givesComputing separately needs four block multiplications. Merely halving the operands therefore gives an ideal recurrence relation , still with quadratic time complexity. The Karatsuba three-product identity instead computes , and , recovering the middle coefficient by two subtractions. The MIT notes present precisely this four-product versus three-product distinction.[ref]
Lecture 11: Numerics I. 6.006 Introduction to Algorithms, Fall 2011, Lecture 11: Numerics I, printed pp. 4–5, High Precision Multiplication and Karatsuba's Method
For an original small example, multiply by . Set , , , , . Four separate block products would give , , , . The three-product calculation isThe crucial reuse is that and supply the outer coefficients and also remove the unwanted terms from . There is no need to compute and separately. Expanding proves the identity. Induction extends it to Karatsuba multiplication once each smaller block product is correct and Karatsuba recursion termination supplies decreasing sizes and complete base cases.
Four block products or three: the exact ledger for
. The left ledger computes both cross products separately. The right ledger reuses and to recover their sum as . Both reconstructions yield . Counts refer to block multiplication calls at this split; the extra numeral digit in prevents interpreting all three as single-digit products. Details.The operation model matters. Let count numeral digits in fixed radix , and count single-digit multiplication, addition, subtraction and copying as constant-cost operations. The nonrecursive work on size- operands is : it includes forming sums, positional shifts and Karatsuba carry handling. Treating an arbitrarily large integer multiplication as one operation would hide the very saving being studied. The coefficients above must be shifted and added; concatenating them does not give .
In the ideal equal-half model, Karatsuba multiplication has . At depth its additional work is at most a constant times , and its leaf count is for . A geometric series gives , where . Four recursive products would instead give leaves. Saving one block product repeatedly changes the exponent, even though the combination requires extra addition and subtraction.
For the literal sum-based version, each operand sum can occupy one extra numeral digit. Its worst-case upper recurrence relation is for a nondecreasing cost envelope, above a fixed base case threshold of at least three digits. Karatsuba digit-operation cost proves that this extra digit preserves the exponent; Karatsuba operand splitting handles odd lengths and leading zero padding. For signed integers, apply the nonnegative procedure to their absolute values and restore the sign. The small ledger establishes an exact identity, while Karatsuba practical crossover explains why it alone cannot predict a speedup for two-digit operands.
Karatsuba multiplication Created 2026-09-28 Updated 2026-10-13
Karatsuba multiplication is a divide-and-conquer algorithm for multiplication of integers. Splitting each operand into two blocks seems to require four smaller products; the Karatsuba three-product identity recovers the two cross terms together from just three products. Repeating that saving through recursion changes the time complexity from quadratic to , where counts digits in a fixed positional notation. The exponent is about : the benefit comes from the algorithm, even though each splitting step needs more addition and subtraction.
The Karatsuba worked multiplication below computes using , , and . The last operand already shows why “half-size” needs care: Karatsuba carry handling and Karatsuba recursion termination account for the extra digit. Karatsuba digit-operation cost states the operation model; Karatsuba practical crossover explains why the asymptotic saving alone does not select a useful threshold.
The original 1962 paper presents a binary numeral system automaton construction: its Theorem 2 and proof reduce multiplication to taking squares of numbers, then reduce a larger square of a number to three smaller squares of numbers. Its footnote explicitly addresses the extra digit in a sum of halves. The sequential time complexity analysis below uses a different operation model from that paper's automaton size and depth bounds, including its Boolean circuit realization without feedback.[ref]
Multiplication of many-digital numbers by automatic computers by A. Karatsuba and Yu. Ofman. Karatsuba and Ofman, Multiplication of many-digital numbers by automatic computers, original Russian article, 1962, pp. 293–294: Theorem 2, its proof, and the footnote on p. 294
Karatsuba recursion termination 2026-10-13
For the sum-based Karatsuba three-product identity, a safe fixed base-case threshold is three digits or more. Return zero directly if either operand is zero; at or below the threshold, use ordinary digit-by-digit multiplication. Otherwise split by the maximum current operand length and invoke Karatsuba multiplication on , , and .
Each recursive operand has at most digits. This is strictly less than for , proving termination. A rule stopping only at one digit does not supply this guarantee: in base two, splits into , whose sum is , still two digits. An implementation must choose a sufficient threshold or explicitly handle such nonshrinking calls. Leading zero padding must not be repeatedly added in a way that defeats the decreasing size measure.
For signed integers, multiply absolute values with the same nonnegative procedure and restore the sign afterwards. This changes the representation bookkeeping, rather than the three-product identity.
Past exam of the mathematics course of the University of Cambridge 2023 iii Paper 124 3 ii Solution 2026-09-28
Split two -digit numbers into high and low halves:where is the base raised to . Their product isThe Karatsuba multiplication identitycomputes the three required half-size products , , and , soSince , induction gives . For ,Padding an arbitrary input length to the next power of two changes only the constant, yielding digit multiplications with .
