Skip to content
CoreSource checked

Dancing Links

Dancing Links handles exact cover search by using linked-list removal and restoration to implement Algorithm X efficiently.

Quick Facts

Compact metadata for implementation and discovery.

Category
Optimization
Difficulty
Intermediate
Family
Exact Cover
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
0
Relationships
7
Code example
Ready
Visualization
Ready

Overview

Dancing Links handles exact cover search by using linked-list removal and restoration to implement Algorithm X efficiently.

Core Concepts

exact cover searchexact coveroptimization

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(1)

Average

O(n)

Worst

O(n)

Space

O(1)

When to Use

  • Use Dancing Links when solving exact cover and you want to benefit from using linked-list removal and restoration to implement Algorithm X efficiently.
  • Choose it when O(n) average/worst-case time and O(1) memory match your workload profile.
  • Prefer it over Greedy Set Cover or Algorithm X when the problem structure favors exact cover search.

When Not to Use

  • Avoid when exact optimality is required but the method is heuristic or approximate.
  • Avoid when constraints are poorly defined or cheap feasibility checks are unavailable.

What It Does

  • Computes exact cover within Exact Cover workloads (O(n) time, O(1) space).
  • Works by using linked-list removal and restoration to implement Algorithm X efficiently.
  • Maintains key invariants across exact cover search, exact cover, optimization.

Use Cases

  • Production and research workloads requiring exact cover via using linked-list removal and restoration to implement Algorithm X efficiently.
  • Exact Cover pipelines where O(n) time and O(1) space fit system constraints.
  • Engineering comparisons against Greedy Set Cover and Algorithm X when tuning exact cover.

Inputs

  • Objective, constraints, and candidate variables
  • Problem-specific costs or feasibility rules

Outputs

  • Best known feasible solution
  • Optimality or approximation result when available

Pseudocode

  1. 1.Formulate the exact cover instance, objective function, and initial candidate state or active search tree.
  2. 2.Evaluate candidate feasibility and objective bounds (exact cover search, exact cover).
  3. 3.Advance the search by using linked-list removal and restoration to implement Algorithm X efficiently.
  4. 4.Prune suboptimal branches, propagate unit/conflict clauses, or update incumbent best solutions.
  5. 5.Return the optimal or best-found feasible assignment once convergence or exhaustion is reached.

Canonical Example

Input
Objective, constraints, and candidate variables configured for a representative exact cover test case
Output
Best known feasible solution satisfying Dancing Links invariants
Explanation
Dancing Links processes the input by using linked-list removal and restoration to implement Algorithm X efficiently, tracking exact cover search and exact cover to produce the verified exact cover result.

Implementation Notes

  • State the objective and feasibility checks in code before adding pruning.
  • Keep incumbent solutions separate from bounds.
  • Add tests for infeasible and exactly-tied cases.

Common Pitfalls

  • Assuming a heuristic is exact without checking its guarantee.
  • Using weak bounds that make search behave like brute force.
  • Forgetting infeasible, empty, or degenerate constraint cases.

Interactive Mechanism Walkthrough

Iterative Convergence & State Trajectory

Show using linked-list removal and restoration to implement Algorithm X efficiently on a small exact cover search example.

Dancing Links mechanism walkthrough step 1 of 5x₀x₁x₂x*
Step 1 of 5: Formulate the exact cover instance, objective function, and initial candidate state or active search tree.
optimization-mechanism

Notes

Dancing Links operates in O(n) time and O(1) space within the Exact Cover family. Often compared with Greedy Set Cover and Algorithm X.

Sources (1)

What each reference supports for this entry.

Dancing Links

Paper

Original paper describing reversible linked-list updates for efficient Algorithm X exact-cover search.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Conceptual neighborGreedy Set Cover

Dancing Links and Greedy Set Cover both relate to exact cover search, but use different structures or assumptions.

Dancing Links uses Algorithm X as a subroutine, representation, or supporting idea while using linked-list removal and restoration to implement Algorithm X efficiently.

Conceptual neighborBranch-and-Bound Set Packing

Dancing Links and Branch-and-Bound Set Packing both relate to exact cover search, but use different structures or assumptions.

Tags

Optimization