<s>
The	O
SMAWK	B-Algorithm
algorithm	I-Algorithm
is	O
an	O
algorithm	O
for	O
finding	O
the	O
minimum	O
value	O
in	O
each	O
row	O
of	O
an	O
implicitly-defined	O
totally	O
monotone	O
matrix	B-Architecture
.	O
</s>
<s>
For	O
the	O
purposes	O
of	O
this	O
algorithm	O
,	O
a	O
matrix	B-Architecture
is	O
defined	O
to	O
be	O
monotone	O
if	O
each	O
row	O
's	O
minimum	O
value	O
occurs	O
in	O
a	O
column	O
which	O
is	O
equal	O
to	O
or	O
greater	O
than	O
the	O
column	O
of	O
the	O
previous	O
row	O
's	O
minimum	O
.	O
</s>
<s>
It	O
is	O
totally	O
monotone	O
if	O
the	O
same	O
property	O
is	O
true	O
for	O
every	O
submatrix	O
(	O
defined	O
by	O
an	O
arbitrary	O
subset	O
of	O
the	O
rows	O
and	O
columns	O
of	O
the	O
given	O
matrix	B-Architecture
)	O
.	O
</s>
<s>
Equivalently	O
,	O
a	O
matrix	B-Architecture
is	O
totally	O
monotone	O
if	O
there	O
does	O
not	O
exist	O
a	O
2×2	O
submatrix	O
whose	O
row	O
minima	O
are	O
in	O
the	O
top	O
right	O
and	O
bottom	O
left	O
corners	O
.	O
</s>
<s>
For	O
the	O
SMAWK	B-Algorithm
algorithm	I-Algorithm
,	O
the	O
matrix	B-Architecture
to	O
be	O
searched	O
should	O
be	O
defined	O
as	O
a	O
function	O
,	O
and	O
this	O
function	O
is	O
given	O
as	O
input	O
to	O
the	O
algorithm	O
(	O
together	O
with	O
the	O
dimensions	O
of	O
the	O
matrix	B-Architecture
)	O
.	O
</s>
<s>
The	O
algorithm	O
then	O
evaluates	O
the	O
function	O
whenever	O
it	O
needs	O
to	O
know	O
the	O
value	O
of	O
a	O
particular	O
matrix	B-Architecture
cell	O
.	O
</s>
<s>
If	O
this	O
evaluation	O
takes	O
O(1 )	O
,	O
then	O
,	O
for	O
a	O
matrix	B-Architecture
with	O
r	O
rows	O
and	O
c	O
columns	O
,	O
the	O
running	O
time	O
and	O
number	O
of	O
function	O
evaluations	O
are	O
both	O
O( c( 1+log( 	O
r/c	O
)	O
)	O
)	O
.	O
</s>
<s>
This	O
is	O
much	O
faster	O
than	O
the	O
O(r c )	O
time	O
of	O
a	O
naive	O
algorithm	O
that	O
evaluates	O
all	O
matrix	B-Architecture
cells	O
.	O
</s>
<s>
The	O
basic	O
idea	O
of	O
the	O
algorithm	O
is	O
to	O
follow	O
a	O
prune	B-Algorithm
and	I-Algorithm
search	I-Algorithm
strategy	O
in	O
which	O
the	O
problem	O
to	O
be	O
solved	O
is	O
reduced	O
to	O
a	O
single	O
recursive	O
subproblem	O
of	O
the	O
same	O
type	O
whose	O
size	O
is	O
smaller	O
by	O
a	O
constant	O
factor	O
.	O
</s>
<s>
To	O
do	O
so	O
,	O
the	O
algorithm	O
first	O
preprocesses	O
the	O
matrix	B-Architecture
to	O
remove	O
some	O
of	O
its	O
columns	O
that	O
cannot	O
contain	O
a	O
row-minimum	O
,	O
using	O
a	O
stack-based	O
algorithm	O
similar	O
to	O
the	O
one	O
in	O
the	O
Graham	B-Algorithm
scan	I-Algorithm
and	O
all	B-Operating_System
nearest	I-Operating_System
smaller	I-Operating_System
values	I-Operating_System
algorithms	O
.	O
</s>
<s>
Next	O
,	O
the	O
algorithm	O
calls	O
itself	O
recursively	O
to	O
find	O
the	O
row	O
minima	O
of	O
the	O
even-numbered	O
rows	O
of	O
the	O
matrix	B-Architecture
.	O
</s>
<s>
Subsequent	O
research	O
found	O
applications	O
of	O
the	O
same	O
algorithm	O
in	O
breaking	B-Algorithm
paragraphs	I-Algorithm
into	I-Algorithm
lines	I-Algorithm
,	O
RNA	O
secondary	O
structure	O
prediction	O
,	O
DNA	O
and	O
protein	B-Algorithm
sequence	I-Algorithm
alignment	I-Algorithm
,	O
the	O
construction	O
of	O
prefix	B-Algorithm
codes	I-Algorithm
,	O
and	O
image	B-Algorithm
thresholding	I-Algorithm
,	O
among	O
others	O
.	O
</s>
