<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
Hirschberg	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
,	O
named	O
after	O
its	O
inventor	O
,	O
Dan	O
Hirschberg	O
,	O
is	O
a	O
dynamic	B-Algorithm
programming	I-Algorithm
algorithm	O
that	O
finds	O
the	O
optimal	O
sequence	B-Algorithm
alignment	I-Algorithm
between	O
two	O
strings	O
.	O
</s>
<s>
Hirschberg	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
simply	O
described	O
as	O
a	O
more	O
space-efficient	O
version	O
of	O
the	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
algorithm	I-Algorithm
that	O
uses	O
divide	B-Algorithm
and	I-Algorithm
conquer	I-Algorithm
.	O
</s>
<s>
Hirschberg	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
commonly	O
used	O
in	O
computational	O
biology	O
to	O
find	O
maximal	O
global	O
alignments	O
of	O
DNA	O
and	O
protein	O
sequences	O
.	O
</s>
<s>
Hirschberg	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
a	O
generally	O
applicable	O
algorithm	O
for	O
optimal	O
sequence	B-Algorithm
alignment	I-Algorithm
.	O
</s>
<s>
BLAST	B-Application
and	O
FASTA	B-Application
are	O
suboptimal	O
heuristics	B-Algorithm
.	O
</s>
<s>
If	O
x	O
and	O
y	O
are	O
strings	O
,	O
where	O
length(x )	O
=	O
n	O
and	O
length(y )	O
=	O
m	O
,	O
the	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
algorithm	I-Algorithm
finds	O
an	O
optimal	O
alignment	O
in	O
O(nm )	O
time	O
,	O
using	O
O(nm )	O
space	O
.	O
</s>
<s>
Hirschberg	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
is	O
a	O
clever	O
modification	O
of	O
the	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
Algorithm	I-Algorithm
,	O
which	O
still	O
takes	O
O(nm )	O
time	O
,	O
but	O
needs	O
only	O
O( min{n	O
,	O
m}	O
)	O
space	O
and	O
is	O
much	O
faster	O
in	O
practice	O
.	O
</s>
<s>
One	O
application	O
of	O
the	O
algorithm	O
is	O
finding	O
sequence	B-Algorithm
alignments	I-Algorithm
of	O
DNA	O
or	O
protein	O
sequences	O
.	O
</s>
<s>
It	O
is	O
also	O
a	O
space-efficient	O
way	O
to	O
calculate	O
the	O
longest	O
common	O
subsequence	O
between	O
two	O
sets	O
of	O
data	O
such	O
as	O
with	O
the	O
common	O
diff	B-Application
tool	O
.	O
</s>
<s>
The	O
Hirschberg	B-Algorithm
algorithm	I-Algorithm
can	O
be	O
derived	O
from	O
the	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
algorithm	I-Algorithm
by	O
observing	O
that	O
:	O
</s>
<s>
one	O
can	O
compute	O
the	O
optimal	O
alignment	O
score	O
by	O
only	O
storing	O
the	O
current	O
and	O
previous	O
row	O
of	O
the	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
score	O
matrix	O
;	O
</s>
<s>
We	O
define	O
,	O
which	O
returns	O
the	O
last	O
line	O
of	O
the	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
score	O
matrix	O
:	O
</s>
<s>
The	O
Hirschberg	B-Algorithm
algorithm	I-Algorithm
follows	O
:	O
</s>
<s>
Indeed	O
,	O
this	O
can	O
be	O
verified	O
by	O
backtracking	O
its	O
corresponding	O
Needleman	B-Algorithm
–	I-Algorithm
Wunsch	I-Algorithm
matrix	O
:	O
</s>
