#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 4B::7.2.2.1 Dancing Links (part 1)
#columns:Front	Back	Tags
TAOCP §7.2.2.1 Dancing Links (part 1): what does it cover?	Part 1 covers pages 65 to 78 of 7.2.2.1. Deleting a node from a doubly linked list and later restoring it from its own stale links is the 'dance'. With it, Algorithm X backtracks over exact cover problems (items and options), using the minimum-remaining-values heuristic to pick an item. The text then adds secondary items (covered at most once), progress reports for long runs, and a long sudoku study: the exact cover model, naked and hidden singles, and variants like jigsaw sudoku.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::about
TAOCP §7.2.2.1 (part 1): why does it matter?	Dancing links is one of Knuth's most famous techniques. Exact cover models sudoku, polyomino tiling and many scheduling problems.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::why
Dancing links: what is it?	Dancing links is a technique for backtracking in which nodes are removed from doubly linked lists and later restored from their own stale pointers, used by Knuth's Algorithm X to solve exact cover problems.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::definition
Dancing links: Who invented dancing links?	The link-removal trick predates Knuth (he credits Hitotumatu and Noshita, 1979), but Knuth named it &quot;dancing links&quot;, popularized it in a 2000 paper and built Algorithm X around it.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::definition
Dancing links: Is DLX the fastest sudoku solver?	It solves any sudoku in a blink and is easy to get right, but hand-tuned constraint solvers can be faster. Its strength is that one program handles every exact cover puzzle.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::definition
Exact cover: what is it?	An exact cover problem gives a set of items and a collection of options, each a subset of the items, and asks for options that together contain every item exactly once.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::definition
Exact cover: Is exact cover NP-complete?	Yes, it is one of Karp's classic NP-complete problems. Good heuristics still solve real puzzle instances quickly.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::definition
TAOCP §7.2.2.1 (part 1), a common trap: “Restoring links in the wrong order on backtrack.” What's the catch?	It must be the exact reverse of removal.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::trap
TAOCP §7.2.2.1 (part 1), a common trap: “Making the queens' diagonals primary items.” What's the catch?	They must be secondary, since not every diagonal gets a queen.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::trap
TAOCP §7.2.2.1 (part 1), a common trap: “Skipping the MRV heuristic.” What's the catch?	Without it Algorithm X can be orders of magnitude slower.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::trap
TAOCP §7.2.2.1 (part 1), exercise 9 (rated 18): what is it asking?	Implement the minimum-remaining-values choice of item. You will use it in every later algorithm.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 11 (rated 19, recommended): what is it asking?	Run Algorithm X by hand on Table 1 and record the memory contents. The best way to see the dance.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 12 (rated 21, recommended): what is it asking?	Print the option that a given node belongs to. A small, useful debugging routine.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 14 (rated 20, recommended): what is it asking?	Model the ménage seating problem as exact cover and count solutions.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 19 (rated 21, recommended): what is it asking?	Change Algorithm X to work with no primary items at all, with a sensible definition of a solution.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 22 (rated 28, recommended): what is it asking?	Use pairwise encoding to cut n queens solutions by symmetry, case by case.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 40 (rated 21, recommended): what is it asking?	Count exact cover solutions with bitwise vectors instead of links. A totally different approach.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1), exercise 67 (rated 22, recommended): what is it asking?	Find the hidden extra constraints in hypersudoku and use them to solve puzzles.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercise
TAOCP §7.2.2.1 (part 1): how many exercises, and how are they rated?	77 exercises, rated M04 to 47.	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::exercises
TAOCP §7.2.2.1 (part 1): what should you be comfortable with first?	<ul><li>2.2.5 Doubly Linked Lists</li><li>7.2.2 Backtrack Programming</li></ul>	cracked.guide cracked.guide::phase::taocp-4b cracked.guide::section::7.2.2.1 cracked.guide::kind::prereqs
