<s>
A	O
greedy	B-Algorithm
algorithm	I-Algorithm
is	O
any	O
algorithm	O
that	O
follows	O
the	O
problem-solving	O
heuristic	B-Algorithm
of	O
making	O
the	O
locally	O
optimal	O
choice	O
at	O
each	O
stage	O
.	O
</s>
<s>
In	O
many	O
problems	O
,	O
a	O
greedy	O
strategy	O
does	O
not	O
produce	O
an	O
optimal	O
solution	O
,	O
but	O
a	O
greedy	B-Algorithm
heuristic	I-Algorithm
can	O
yield	O
locally	O
optimal	O
solutions	O
that	O
approximate	O
a	O
globally	O
optimal	O
solution	O
in	O
a	O
reasonable	O
amount	O
of	O
time	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
greedy	O
strategy	O
for	O
the	O
travelling	B-Algorithm
salesman	I-Algorithm
problem	I-Algorithm
(	O
which	O
is	O
of	O
high	O
computational	O
complexity	O
)	O
is	O
the	O
following	O
heuristic	B-Algorithm
:	O
"	O
At	O
each	O
step	O
of	O
the	O
journey	O
,	O
visit	O
the	O
nearest	O
unvisited	O
city.	O
"	O
</s>
<s>
This	O
heuristic	B-Algorithm
does	O
not	O
intend	O
to	O
find	O
the	O
best	O
solution	O
,	O
but	O
it	O
terminates	O
in	O
a	O
reasonable	O
number	O
of	O
steps	O
;	O
finding	O
an	O
optimal	O
solution	O
to	O
such	O
a	O
complex	O
problem	O
typically	O
requires	O
unreasonably	O
many	O
steps	O
.	O
</s>
<s>
In	O
mathematical	O
optimization	O
,	O
greedy	B-Algorithm
algorithms	I-Algorithm
optimally	O
solve	O
combinatorial	O
problems	O
having	O
the	O
properties	O
of	O
matroids	O
and	O
give	O
constant-factor	O
approximations	O
to	O
optimization	O
problems	O
with	O
the	O
submodular	B-Algorithm
structure	O
.	O
</s>
<s>
Greedy	B-Algorithm
algorithms	I-Algorithm
produce	O
good	O
solutions	O
on	O
some	O
mathematical	O
problems	O
,	O
but	O
not	O
on	O
others	O
.	O
</s>
<s>
The	O
choice	O
made	O
by	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
may	O
depend	O
on	O
choices	O
made	O
so	O
far	O
,	O
but	O
not	O
on	O
future	O
choices	O
or	O
all	O
the	O
solutions	O
to	O
the	O
subproblem	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
never	O
reconsiders	O
its	O
choices	O
.	O
</s>
<s>
This	O
is	O
the	O
main	O
difference	O
from	O
dynamic	B-Algorithm
programming	I-Algorithm
,	O
which	O
is	O
exhaustive	O
and	O
is	O
guaranteed	O
to	O
find	O
the	O
solution	O
.	O
</s>
<s>
After	O
every	O
stage	O
,	O
dynamic	B-Algorithm
programming	I-Algorithm
makes	O
decisions	O
based	O
on	O
all	O
the	O
decisions	O
made	O
in	O
the	O
previous	O
stage	O
and	O
may	O
reconsider	O
the	O
previous	O
stage	O
's	O
algorithmic	O
path	O
to	O
the	O
solution	O
.	O
</s>
<s>
Optimal	B-Algorithm
substructure	I-Algorithm
"	O
A	O
problem	O
exhibits	O
optimal	B-Algorithm
substructure	I-Algorithm
if	O
an	O
optimal	O
solution	O
to	O
the	O
problem	O
contains	O
optimal	O
solutions	O
to	O
the	O
sub-problems.	O
"	O
</s>
<s>
Greedy	B-Algorithm
algorithms	I-Algorithm
fail	O
to	O
produce	O
the	O
optimal	O
solution	O
for	O
many	O
other	O
problems	O
and	O
may	O
even	O
produce	O
the	O
unique	O
worst	O
possible	O
solution	O
.	O
</s>
<s>
One	O
example	O
is	O
the	O
travelling	B-Algorithm
salesman	I-Algorithm
problem	I-Algorithm
mentioned	O
above	O
:	O
for	O
each	O
number	O
of	O
cities	O
,	O
there	O
is	O
an	O
assignment	O
of	O
distances	O
between	O
the	O
cities	O
for	O
which	O
the	O
nearest-neighbour	O
heuristic	B-Algorithm
produces	O
the	O
unique	O
worst	O
possible	O
tour	O
.	O
</s>
<s>
For	O
other	O
possible	O
examples	O
,	O
see	O
horizon	B-General_Concept
effect	I-General_Concept
.	O
</s>
<s>
Greedy	B-Algorithm
algorithms	I-Algorithm
can	O
be	O
characterized	O
as	O
being	O
'	O
short	O
sighted	O
 '	O
,	O
and	O
also	O
as	O
'	O
non-recoverable	O
'	O
.	O
</s>
<s>
They	O
are	O
ideal	O
only	O
for	O
problems	O
that	O
have	O
an	O
'	O
optimal	B-Algorithm
substructure	I-Algorithm
 '	O
.	O
</s>
<s>
It	O
is	O
important	O
,	O
however	O
,	O
to	O
note	O
that	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
can	O
be	O
used	O
as	O
a	O
selection	O
algorithm	O
to	O
prioritize	O
options	O
within	O
a	O
search	O
,	O
or	O
branch-and-bound	O
algorithm	O
.	O
</s>
<s>
There	O
are	O
a	O
few	O
variations	O
to	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
:	O
</s>
<s>
Greedy	B-Algorithm
algorithms	I-Algorithm
have	O
a	O
long	O
history	O
of	O
study	O
in	O
combinatorial	O
optimization	O
and	O
theoretical	O
computer	O
science	O
.	O
</s>
<s>
Greedy	B-Algorithm
heuristics	I-Algorithm
are	O
known	O
to	O
produce	O
suboptimal	O
results	O
on	O
many	O
problems	O
,	O
and	O
so	O
natural	O
questions	O
are	O
:	O
</s>
<s>
For	O
which	O
problems	O
do	O
greedy	B-Algorithm
algorithms	I-Algorithm
perform	O
optimally	O
?	O
</s>
<s>
For	O
which	O
problems	O
do	O
greedy	B-Algorithm
algorithms	I-Algorithm
guarantee	O
an	O
approximately	O
optimal	O
solution	O
?	O
</s>
<s>
For	O
which	O
problems	O
are	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
guaranteed	O
not	O
to	O
produce	O
an	O
optimal	O
solution	O
?	O
</s>
<s>
A	O
large	O
body	O
of	O
literature	O
exists	O
answering	O
these	O
questions	O
for	O
general	O
classes	O
of	O
problems	O
,	O
such	O
as	O
matroids	O
,	O
as	O
well	O
as	O
for	O
specific	O
problems	O
,	O
such	O
as	O
set	B-Algorithm
cover	I-Algorithm
.	O
</s>
<s>
If	O
an	O
optimization	O
problem	O
has	O
the	O
structure	O
of	O
a	O
matroid	O
,	O
then	O
the	O
appropriate	O
greedy	B-Algorithm
algorithm	I-Algorithm
will	O
solve	O
it	O
optimally	O
.	O
</s>
<s>
A	O
function	O
defined	O
on	O
subsets	O
of	O
a	O
set	O
is	O
called	O
submodular	B-Algorithm
if	O
for	O
every	O
we	O
have	O
that	O
.	O
</s>
<s>
The	O
greedy	B-Algorithm
algorithm	I-Algorithm
,	O
which	O
builds	O
up	O
a	O
set	O
by	O
incrementally	O
adding	O
the	O
element	O
which	O
increases	O
the	O
most	O
at	O
each	O
step	O
,	O
produces	O
as	O
output	O
a	O
set	O
that	O
is	O
at	O
least	O
.	O
</s>
<s>
Similar	O
guarantees	O
are	O
provable	O
when	O
additional	O
constraints	O
,	O
such	O
as	O
cardinality	O
constraints	O
,	O
are	O
imposed	O
on	O
the	O
output	O
,	O
though	O
often	O
slight	O
variations	O
on	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
are	O
required	O
.	O
</s>
<s>
Many	O
of	O
these	O
problems	O
have	O
matching	O
lower	O
bounds	O
;	O
i.e.	O
,	O
the	O
greedy	B-Algorithm
algorithm	I-Algorithm
does	O
not	O
perform	O
better	O
than	O
the	O
guarantee	O
in	O
the	O
worst	O
case	O
.	O
</s>
<s>
Greedy	B-Algorithm
algorithms	I-Algorithm
typically	O
(	O
but	O
not	O
always	O
)	O
fail	O
to	O
find	O
the	O
globally	O
optimal	O
solution	O
because	O
they	O
usually	O
do	O
not	O
operate	O
exhaustively	O
on	O
all	O
the	O
data	O
.	O
</s>
<s>
If	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
can	O
be	O
proven	O
to	O
yield	O
the	O
global	O
optimum	O
for	O
a	O
given	O
problem	O
class	O
,	O
it	O
typically	O
becomes	O
the	O
method	O
of	O
choice	O
because	O
it	O
is	O
faster	O
than	O
other	O
optimization	O
methods	O
like	O
dynamic	B-Algorithm
programming	I-Algorithm
.	O
</s>
<s>
Examples	O
of	O
such	O
greedy	B-Algorithm
algorithms	I-Algorithm
are	O
Kruskal	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
and	O
Prim	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
for	O
finding	O
minimum	O
spanning	O
trees	O
and	O
the	O
algorithm	O
for	O
finding	O
optimum	O
Huffman	B-General_Concept
trees	I-General_Concept
.	O
</s>
<s>
Greedy	B-Algorithm
algorithms	I-Algorithm
appear	O
in	O
the	O
network	B-Protocol
routing	I-Protocol
as	O
well	O
.	O
</s>
<s>
Using	O
greedy	O
routing	B-Protocol
,	O
a	O
message	O
is	O
forwarded	O
to	O
the	O
neighbouring	O
node	O
which	O
is	O
"	O
closest	O
"	O
to	O
the	O
destination	O
.	O
</s>
<s>
The	O
notion	O
of	O
a	O
node	O
's	O
location	O
(	O
and	O
hence	O
"	O
closeness	O
"	O
)	O
may	O
be	O
determined	O
by	O
its	O
physical	O
location	O
,	O
as	O
in	O
geographic	B-Protocol
routing	I-Protocol
used	O
by	O
ad	B-Protocol
hoc	I-Protocol
networks	I-Protocol
.	O
</s>
<s>
Location	O
may	O
also	O
be	O
an	O
entirely	O
artificial	O
construct	O
as	O
in	O
small	O
world	O
routing	B-Protocol
and	O
distributed	B-Operating_System
hash	I-Operating_System
table	I-Operating_System
.	O
</s>
<s>
The	O
activity	B-Algorithm
selection	I-Algorithm
problem	I-Algorithm
is	O
characteristic	O
of	O
this	O
class	O
of	O
problems	O
,	O
where	O
the	O
goal	O
is	O
to	O
pick	O
the	O
maximum	O
number	O
of	O
activities	O
that	O
do	O
not	O
clash	O
with	O
each	O
other	O
.	O
</s>
<s>
In	O
the	O
Macintosh	B-Device
computer	I-Device
game	O
Crystal	B-Device
Quest	I-Device
the	O
objective	O
is	O
to	O
collect	O
crystals	O
,	O
in	O
a	O
fashion	O
similar	O
to	O
the	O
travelling	B-Algorithm
salesman	I-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
The	O
game	O
has	O
a	O
demo	O
mode	O
,	O
where	O
the	O
game	O
uses	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
to	O
go	O
to	O
every	O
crystal	O
.	O
</s>
<s>
The	B-Application
artificial	I-Application
intelligence	I-Application
does	O
not	O
account	O
for	O
obstacles	O
,	O
so	O
the	O
demo	O
mode	O
often	O
ends	O
quickly	O
.	O
</s>
<s>
The	O
matching	B-General_Concept
pursuit	I-General_Concept
is	O
an	O
example	O
of	O
a	O
greedy	B-Algorithm
algorithm	I-Algorithm
applied	O
on	O
signal	O
approximation	O
.	O
</s>
<s>
A	O
greedy	B-Algorithm
algorithm	I-Algorithm
finds	O
the	O
optimal	O
solution	O
to	O
Malfatti	O
's	O
problem	O
of	O
finding	O
three	O
disjoint	O
circles	O
within	O
a	O
given	O
triangle	O
that	O
maximize	O
the	O
total	O
area	O
of	O
the	O
circles	O
;	O
it	O
is	O
conjectured	O
that	O
the	O
same	O
greedy	B-Algorithm
algorithm	I-Algorithm
is	O
optimal	O
for	O
any	O
number	O
of	O
circles	O
.	O
</s>
<s>
A	O
greedy	B-Algorithm
algorithm	I-Algorithm
is	O
used	O
to	O
construct	O
a	O
Huffman	B-General_Concept
tree	I-General_Concept
during	O
Huffman	B-General_Concept
coding	I-General_Concept
where	O
it	O
finds	O
an	O
optimal	O
solution	O
.	O
</s>
<s>
In	O
decision	B-Algorithm
tree	I-Algorithm
learning	I-Algorithm
,	O
greedy	B-Algorithm
algorithms	I-Algorithm
are	O
commonly	O
used	O
,	O
however	O
they	O
are	O
not	O
guaranteed	O
to	O
find	O
the	O
optimal	O
solution	O
.	O
</s>
<s>
One	O
popular	O
such	O
algorithm	O
is	O
the	O
ID3	B-Algorithm
algorithm	I-Algorithm
for	O
decision	O
tree	O
construction	O
.	O
</s>
<s>
Dijkstra	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
and	O
the	O
related	O
A*	B-Protocol
search	I-Protocol
algorithm	I-Protocol
are	O
verifiably	O
optimal	O
greedy	B-Algorithm
algorithms	I-Algorithm
for	O
graph	B-Algorithm
search	I-Algorithm
and	O
shortest	O
path	O
finding	O
.	O
</s>
<s>
A*	B-Protocol
search	I-Protocol
is	O
conditionally	O
optimal	O
,	O
requiring	O
an	O
"	O
admissible	B-General_Concept
heuristic	I-General_Concept
"	O
that	O
will	O
not	O
overestimate	O
path	O
costs	O
.	O
</s>
<s>
Kruskal	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
and	O
Prim	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
are	O
greedy	B-Algorithm
algorithms	I-Algorithm
for	O
constructing	O
minimum	O
spanning	O
trees	O
of	O
a	O
given	O
connected	O
graph	O
.	O
</s>
