Exact cover is a deceptively simple question: given a universe of items and a collection of sets, can you choose a sub-collection such that every item appears in exactly one chosen set? No gaps, no overlaps — perfect coverage.
The puzzle appears everywhere. Can twelve pentomino pieces tile a 6×10 rectangle with no overlap? Can 81 Sudoku cells be filled so each digit covers each row, column, and box exactly once? Both reduce to exact cover, and exact cover is NP-complete.
In 2000, Donald Knuth published "Dancing Links" — a paper that shows how to solve exact-cover problems with breathtaking efficiency. The key insight is not an algorithmic trick but a data-structure one: represent the constraint matrix as a doubly-linked toroidal list, then implement backtracking by unlinking and relinking nodes. When a search branch fails and you need to undo, deleted nodes dance back into place — each node still knows its old neighbors even while removed, so restoration is O(1) per node.
Comments
Loading comments...