← Backtracking · guided lesson

Backtracking

1 / 18 · story

the story

Backtracking (choose → explore → un-choose)

Every tool here exists because something was too slow or broke without it. Here is what.

1950s–1965 · D. H. Lehmer or R. J. Walker (the name); Solomon W. Golomb & Leonard D. Baumert

Who named it is disputed. Golomb and Baumert (1965) say the mathematician D. H. Lehmer named it "backtrack"; Knuth (1975) credits R. J. Walker, who "aptly called" it backtracking. In 1960 Walker published a short note describing it as a general method for combinatorial problems. As Knuth tells it, Walker's 1950s n-queens program already kept the attacked columns and diagonals as bit vectors. In 1965 Golomb and Baumert's "Backtrack Programming" (Journal of the ACM) set the method out with many examples — and, Knuth notes, already suggested branching first on the choice with the fewest options left.

the problem it solved

Searching enormous spaces of combinations on early computers without building every complete candidate first.

why it matters: without it

Every "find all" or "place under rules" problem would mean building every complete candidate and checking it at the end — billions of boards instead of two thousand calls.

sources: Golomb & Baumert — Backtrack Programming (Journal of the ACM 12(4), 1965) ↗ · Walker — An enumerative technique for a class of combinatorial problems (Proc. Symp. Applied Math. 10, AMS, 1960) ↗ · Knuth — The Art of Computer Programming, §7.2.2 Backtrack programming (pre-fascicle 5B) ↗ · Knuth — Estimating the efficiency of backtrack programs (Mathematics of Computation 29, 1975): "which R. J. Walker has aptly called backtracking" ↗ · NIST Dictionary of Algorithms and Data Structures — backtracking (quotes Golomb & Baumert) ↗

also in this chapter: Subsets & combinations (the start index) · Generating permutations · Constraint pruning (N-Queens, Sudoku)