<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
iterative	B-Algorithm
deepening	I-Algorithm
search	I-Algorithm
or	O
more	O
specifically	O
iterative	B-Algorithm
deepening	I-Algorithm
depth-first	I-Algorithm
search	I-Algorithm
(	O
IDS	O
or	O
IDDFS	B-Algorithm
)	O
is	O
a	O
state	O
space/graph	O
search	O
strategy	O
in	O
which	O
a	O
depth-limited	O
version	O
of	O
depth-first	B-Algorithm
search	I-Algorithm
is	O
run	O
repeatedly	O
with	O
increasing	O
depth	O
limits	O
until	O
the	O
goal	O
is	O
found	O
.	O
</s>
<s>
IDDFS	B-Algorithm
is	O
optimal	O
like	O
breadth-first	B-Algorithm
search	I-Algorithm
,	O
but	O
uses	O
much	O
less	O
memory	O
;	O
at	O
each	O
iteration	O
,	O
it	O
visits	O
the	O
nodes	O
in	O
the	O
search	B-Data_Structure
tree	I-Data_Structure
in	O
the	O
same	O
order	O
as	O
depth-first	B-Algorithm
search	I-Algorithm
,	O
but	O
the	O
cumulative	O
order	O
in	O
which	O
nodes	O
are	O
first	O
visited	O
is	O
effectively	O
breadth-first	B-Algorithm
.	O
</s>
<s>
The	O
following	O
pseudocode	O
shows	O
IDDFS	B-Algorithm
implemented	O
in	O
terms	O
of	O
a	O
recursive	O
depth-limited	O
DFS	O
(	O
called	O
DLS	O
)	O
for	O
directed	O
graphs	O
.	O
</s>
<s>
This	O
implementation	O
of	O
IDDFS	B-Algorithm
does	O
not	O
account	O
for	O
already-visited	O
nodes	O
.	O
</s>
<s>
If	O
the	O
goal	O
node	B-Data_Structure
is	O
found	O
,	O
then	O
DLS	O
unwinds	O
the	O
recursion	O
returning	O
with	O
no	O
further	O
iterations	O
.	O
</s>
<s>
Otherwise	O
,	O
if	O
at	O
least	O
one	O
node	B-Data_Structure
exists	O
at	O
that	O
level	O
of	O
depth	O
,	O
the	O
remaining	O
flag	O
will	O
let	O
IDDFS	B-Algorithm
continue	O
.	O
</s>
<s>
2-tuples	B-Application
are	O
useful	O
as	O
return	O
value	O
to	O
signal	O
IDDFS	B-Algorithm
to	O
continue	O
deepening	O
or	O
stop	O
,	O
in	O
case	O
tree	B-Application
depth	O
and	O
goal	O
membership	O
are	O
unknown	O
a	O
priori	O
.	O
</s>
<s>
Another	O
solution	O
could	O
use	O
sentinel	B-Data_Structure
values	I-Data_Structure
instead	O
to	O
represent	O
not	O
found	O
or	O
remaining	O
level	O
results	O
.	O
</s>
<s>
IDDFS	B-Algorithm
combines	O
depth-first	B-Algorithm
search	I-Algorithm
's	O
space-efficiency	O
and	O
breadth-first	B-Algorithm
search	I-Algorithm
's	O
completeness	O
(	O
when	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
is	O
finite	O
)	O
.	O
</s>
<s>
Since	O
iterative	B-Algorithm
deepening	I-Algorithm
visits	O
states	O
multiple	O
times	O
,	O
it	O
may	O
seem	O
wasteful	O
,	O
but	O
it	O
turns	O
out	O
to	O
be	O
not	O
so	O
costly	O
,	O
since	O
in	O
a	O
tree	B-Application
most	O
of	O
the	O
nodes	O
are	O
in	O
the	O
bottom	O
level	O
,	O
so	O
it	O
does	O
not	O
matter	O
much	O
if	O
the	O
upper	O
levels	O
are	O
visited	O
multiple	O
times	O
.	O
</s>
<s>
The	O
main	O
advantage	O
of	O
IDDFS	B-Algorithm
in	O
game	O
tree	B-Application
searching	O
is	O
that	O
the	O
earlier	O
searches	O
tend	O
to	O
improve	O
the	O
commonly	O
used	O
heuristics	O
,	O
such	O
as	O
the	O
killer	B-Algorithm
heuristic	I-Algorithm
and	O
alpha	B-Algorithm
–	I-Algorithm
beta	I-Algorithm
pruning	I-Algorithm
,	O
so	O
that	O
a	O
more	O
accurate	O
estimate	O
of	O
the	O
score	O
of	O
various	O
nodes	O
at	O
the	O
final	O
depth	O
search	O
can	O
occur	O
,	O
and	O
the	O
search	O
completes	O
more	O
quickly	O
since	O
it	O
is	O
done	O
in	O
a	O
better	O
order	O
.	O
</s>
<s>
For	O
example	O
,	O
alpha	B-Algorithm
–	I-Algorithm
beta	I-Algorithm
pruning	I-Algorithm
is	O
most	O
efficient	O
if	O
it	O
searches	O
the	O
best	O
moves	O
first	O
.	O
</s>
<s>
When	O
used	O
in	O
an	O
interactive	O
setting	O
,	O
such	O
as	O
in	O
a	O
chess-playing	B-Application
program	I-Application
,	O
this	O
facility	O
allows	O
the	O
program	O
to	O
play	O
at	O
any	O
time	O
with	O
the	O
current	O
best	O
move	O
found	O
in	O
the	O
search	O
it	O
has	O
completed	O
so	O
far	O
.	O
</s>
<s>
This	O
is	O
not	O
possible	O
with	O
a	O
traditional	O
depth-first	B-Algorithm
search	I-Algorithm
,	O
which	O
does	O
not	O
produce	O
intermediate	O
results	O
.	O
</s>
<s>
The	O
time	O
complexity	O
of	O
IDDFS	B-Algorithm
in	O
a	O
(	O
well-balanced	O
)	O
tree	B-Application
works	O
out	O
to	O
be	O
the	O
same	O
as	O
breadth-first	B-Algorithm
search	I-Algorithm
,	O
i.e.	O
</s>
<s>
,	O
where	O
is	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
and	O
is	O
the	O
depth	O
of	O
the	O
goal	O
.	O
</s>
<s>
Since	O
or	O
is	O
a	O
constant	O
independent	O
of	O
(	O
the	O
depth	O
)	O
,	O
if	O
(	O
i.e.	O
,	O
if	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
is	O
greater	O
than	O
1	O
)	O
,	O
the	O
running	O
time	O
of	O
the	O
depth-first	B-Algorithm
iterative	B-Algorithm
deepening	I-Algorithm
search	I-Algorithm
is	O
.	O
</s>
<s>
All	O
together	O
,	O
an	O
iterative	B-Algorithm
deepening	I-Algorithm
search	I-Algorithm
from	O
depth	O
all	O
the	O
way	O
down	O
to	O
depth	O
expands	O
only	O
about	O
more	O
nodes	O
than	O
a	O
single	O
breadth-first	B-Algorithm
or	O
depth-limited	B-Algorithm
search	I-Algorithm
to	O
depth	O
,	O
when	O
.	O
</s>
<s>
The	O
higher	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
,	O
the	O
lower	O
the	O
overhead	O
of	O
repeatedly	O
expanded	O
states	O
,	O
but	O
even	O
when	O
the	O
branching	B-Data_Structure
factor	I-Data_Structure
is	O
2	O
,	O
iterative	B-Algorithm
deepening	I-Algorithm
search	I-Algorithm
only	O
takes	O
about	O
twice	O
as	O
long	O
as	O
a	O
complete	O
breadth-first	B-Algorithm
search	I-Algorithm
.	O
</s>
<s>
This	O
means	O
that	O
the	O
time	O
complexity	O
of	O
iterative	B-Algorithm
deepening	I-Algorithm
is	O
still	O
.	O
</s>
<s>
The	O
space	O
complexity	O
of	O
IDDFS	B-Algorithm
is	O
,	O
where	O
is	O
the	O
depth	O
of	O
the	O
goal	O
.	O
</s>
<s>
Since	O
IDDFS	B-Algorithm
,	O
at	O
any	O
point	O
,	O
is	O
engaged	O
in	O
a	O
depth-first	B-Algorithm
search	I-Algorithm
,	O
it	O
need	O
only	O
store	O
a	O
stack	O
of	O
nodes	O
which	O
represents	O
the	O
branch	O
of	O
the	O
tree	B-Application
it	O
is	O
expanding	O
.	O
</s>
<s>
In	O
general	O
,	O
iterative	B-Algorithm
deepening	I-Algorithm
is	O
the	O
preferred	O
search	O
method	O
when	O
there	O
is	O
a	O
large	O
search	O
space	O
and	O
the	O
depth	O
of	O
the	O
solution	O
is	O
not	O
known	O
.	O
</s>
<s>
For	O
the	O
following	O
graph	B-Application
:	O
</s>
<s>
a	O
depth-first	B-Algorithm
search	I-Algorithm
starting	O
at	O
A	O
,	O
assuming	O
that	O
the	O
left	O
edges	O
in	O
the	O
shown	O
graph	B-Application
are	O
chosen	O
before	O
right	O
edges	O
,	O
and	O
assuming	O
the	O
search	O
remembers	O
previously-visited	O
nodes	O
and	O
will	O
not	O
repeat	O
them	O
(	O
since	O
this	O
is	O
a	O
small	O
graph	B-Application
)	O
,	O
will	O
visit	O
the	O
nodes	O
in	O
the	O
following	O
order	O
:	O
A	O
,	O
B	O
,	O
D	O
,	O
F	O
,	O
E	O
,	O
C	O
,	O
G	O
.	O
The	O
edges	O
traversed	O
in	O
this	O
search	O
form	O
a	O
Trémaux	O
tree	B-Application
,	O
a	O
structure	O
with	O
important	O
applications	O
in	O
graph	B-Application
theory	O
.	O
</s>
<s>
Iterative	B-Algorithm
deepening	I-Algorithm
prevents	O
this	O
loop	O
and	O
will	O
reach	O
the	O
following	O
nodes	O
on	O
the	O
following	O
depths	O
,	O
assuming	O
it	O
proceeds	O
left-to-right	O
as	O
above	O
:	O
</s>
<s>
(	O
Iterative	B-Algorithm
deepening	I-Algorithm
has	O
now	O
seen	O
C	O
,	O
when	O
a	O
conventional	O
depth-first	B-Algorithm
search	I-Algorithm
did	O
not	O
.	O
)	O
</s>
<s>
For	O
this	O
graph	B-Application
,	O
as	O
more	O
depth	O
is	O
added	O
,	O
the	O
two	O
cycles	O
"	O
ABFE	O
"	O
and	O
"	O
AEFB	O
"	O
will	O
simply	O
get	O
longer	O
before	O
the	O
algorithm	O
gives	O
up	O
and	O
tries	O
another	O
branch	O
.	O
</s>
<s>
Similar	O
to	O
iterative	B-Algorithm
deepening	I-Algorithm
is	O
a	O
search	O
strategy	O
called	O
iterative	O
lengthening	O
search	O
that	O
works	O
with	O
increasing	O
path-cost	O
limits	O
instead	O
of	O
depth-limits	O
.	O
</s>
<s>
But	O
iterative	O
lengthening	O
incurs	O
substantial	O
overhead	O
that	O
makes	O
it	O
less	O
useful	O
than	O
iterative	B-Algorithm
deepening	I-Algorithm
.	O
</s>
<s>
Iterative	B-Protocol
deepening	I-Protocol
A*	I-Protocol
is	O
a	O
best-first	O
search	O
that	O
performs	O
iterative	B-Algorithm
deepening	I-Algorithm
based	O
on	O
""	O
-values	O
similar	O
to	O
the	O
ones	O
computed	O
in	O
the	O
A*	B-Protocol
algorithm	I-Protocol
.	O
</s>
<s>
IDDFS	B-Algorithm
has	O
a	O
bidirectional	O
counterpart	O
,	O
which	O
alternates	O
two	O
searches	O
:	O
one	O
starting	O
from	O
the	O
source	O
node	B-Data_Structure
and	O
moving	O
along	O
the	O
directed	O
arcs	O
,	O
and	O
another	O
one	O
starting	O
from	O
the	O
target	O
node	B-Data_Structure
and	O
proceeding	O
along	O
the	O
directed	O
arcs	O
in	O
opposite	O
direction	O
(	O
from	O
the	O
arc	O
's	O
head	O
node	B-Data_Structure
to	O
the	O
arc	O
's	O
tail	O
node	B-Data_Structure
)	O
.	O
</s>
<s>
The	O
search	O
process	O
first	O
checks	O
that	O
the	O
source	O
node	B-Data_Structure
and	O
the	O
target	O
node	B-Data_Structure
are	O
same	O
,	O
and	O
if	O
so	O
,	O
returns	O
the	O
trivial	O
path	O
consisting	O
of	O
a	O
single	O
source/target	O
node	B-Data_Structure
.	O
</s>
<s>
Otherwise	O
,	O
the	O
forward	O
search	O
process	O
expands	O
the	O
child	O
nodes	O
of	O
the	O
source	O
node	B-Data_Structure
(	O
set	O
)	O
,	O
the	O
backward	O
search	O
process	O
expands	O
the	O
parent	B-Application
nodes	I-Application
of	O
the	O
target	O
node	B-Data_Structure
(	O
set	O
)	O
,	O
and	O
it	O
is	O
checked	O
whether	O
and	O
intersect	O
.	O
</s>
<s>
What	O
comes	O
to	O
space	O
complexity	O
,	O
the	O
algorithm	O
colors	O
the	O
deepest	O
nodes	O
in	O
the	O
forward	O
search	O
process	O
in	O
order	O
to	O
detect	O
existence	O
of	O
the	O
middle	O
node	B-Data_Structure
where	O
the	O
two	O
search	O
processes	O
meet	O
.	O
</s>
<s>
Additional	O
difficulty	O
of	O
applying	O
bidirectional	O
IDDFS	B-Algorithm
is	O
that	O
if	O
the	O
source	O
and	O
the	O
target	O
nodes	O
are	O
in	O
different	O
strongly	O
connected	O
components	O
,	O
say	O
,	O
,	O
if	O
there	O
is	O
no	O
arc	O
leaving	O
and	O
entering	O
,	O
the	O
search	O
will	O
never	O
terminate	O
.	O
</s>
