<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
dancing	B-Algorithm
links	I-Algorithm
(	O
DLX	O
)	O
is	O
a	O
technique	O
for	O
adding	O
and	O
deleting	O
a	O
node	O
from	O
a	O
circular	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
.	O
</s>
<s>
It	O
is	O
particularly	O
useful	O
for	O
efficiently	O
implementing	O
backtracking	B-Algorithm
algorithms	I-Algorithm
,	O
such	O
as	O
Knuth	B-Algorithm
's	I-Algorithm
Algorithm	I-Algorithm
X	I-Algorithm
for	O
the	O
exact	O
cover	O
problem	O
.	O
</s>
<s>
Algorithm	B-Algorithm
X	I-Algorithm
is	O
a	O
recursive	O
,	O
nondeterministic	O
,	O
depth-first	B-Algorithm
,	O
backtracking	B-Algorithm
algorithm	I-Algorithm
that	O
finds	O
all	O
solutions	O
to	O
the	O
exact	O
cover	O
problem	O
.	O
</s>
<s>
Some	O
of	O
the	O
better-known	O
exact	O
cover	O
problems	O
include	O
tiling	B-Algorithm
,	O
the	O
n	O
queens	O
problem	O
,	O
and	O
Sudoku	O
.	O
</s>
<s>
The	O
name	O
dancing	B-Algorithm
links	I-Algorithm
,	O
which	O
was	O
suggested	O
by	O
Donald	O
Knuth	O
,	O
stems	O
from	O
the	O
way	O
the	O
algorithm	O
works	O
,	O
as	O
iterations	O
of	O
the	O
algorithm	O
cause	O
the	O
links	O
to	O
"	O
dance	O
"	O
with	O
partner	O
links	O
so	O
as	O
to	O
resemble	O
an	O
"	O
exquisitely	O
choreographed	O
dance.	O
"	O
</s>
<s>
As	O
the	O
remainder	O
of	O
this	O
article	O
discusses	O
the	O
details	O
of	O
an	O
implementation	O
technique	O
for	O
Algorithm	B-Algorithm
X	I-Algorithm
,	O
the	O
reader	O
is	O
strongly	O
encouraged	O
to	O
read	O
the	O
Algorithm	B-Algorithm
X	I-Algorithm
article	O
first	O
.	O
</s>
<s>
The	O
idea	O
of	O
DLX	O
is	O
based	O
on	O
the	O
observation	O
that	O
in	O
a	O
circular	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
of	O
nodes	O
,	O
</s>
<s>
Knuth	O
observed	O
that	O
a	O
naive	O
implementation	O
of	O
his	O
Algorithm	B-Algorithm
X	I-Algorithm
would	O
spend	O
an	O
inordinate	O
amount	O
of	O
time	O
searching	O
for	O
1	O
's	O
.	O
</s>
<s>
To	O
improve	O
this	O
search	O
time	O
from	O
complexity	O
O(n )	O
to	O
O(1 )	O
,	O
Knuth	O
implemented	O
a	O
sparse	B-Algorithm
matrix	I-Algorithm
where	O
only	O
1	O
's	O
are	O
stored	O
.	O
</s>
<s>
Each	O
row	O
and	O
column	O
in	O
the	O
matrix	O
will	O
consist	O
of	O
a	O
circular	O
doubly-linked	B-Data_Structure
list	I-Data_Structure
of	O
nodes	O
.	O
</s>
<s>
In	O
Algorithm	B-Algorithm
X	I-Algorithm
,	O
rows	O
and	O
columns	O
are	O
regularly	O
eliminated	O
from	O
and	O
restored	O
to	O
the	O
matrix	O
.	O
</s>
<s>
One	O
requirement	O
of	O
using	O
that	O
algorithm	O
is	O
that	O
backtracking	B-Algorithm
must	O
be	O
done	O
as	O
an	O
exact	O
reversal	O
of	O
eliminations	O
.	O
</s>
<s>
Dancing	B-Algorithm
Links	I-Algorithm
accommodates	O
these	O
with	O
primary	O
columns	O
which	O
must	O
be	O
filled	O
and	O
secondary	O
columns	O
which	O
are	O
optional	O
.	O
</s>
