<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
two-way	B-Algorithm
string-matching	I-Algorithm
algorithm	I-Algorithm
is	O
a	O
string-searching	B-Algorithm
algorithm	I-Algorithm
,	O
discovered	O
by	O
Maxime	O
Crochemore	O
and	O
Dominique	O
Perrin	O
in	O
1991	O
.	O
</s>
<s>
The	O
two-way	O
algorithm	O
can	O
be	O
viewed	O
as	O
a	O
combination	O
of	O
the	O
forward-going	O
Knuth	O
–	O
Morris	O
–	O
Pratt	O
algorithm	O
(	O
KMP	O
)	O
and	O
the	O
backward-running	O
Boyer	B-Algorithm
–	I-Algorithm
Moore	I-Algorithm
string-search	I-Algorithm
algorithm	I-Algorithm
(	O
BM	O
)	O
.	O
</s>
<s>
This	O
is	O
sometimes	O
treated	O
as	O
"	O
close	O
enough	O
to	O
O(1 )	O
in	O
practice	O
"	O
,	O
as	O
the	O
needle	O
's	O
size	O
is	O
limited	O
by	O
the	O
size	O
of	O
addressable	B-General_Concept
memory	I-General_Concept
;	O
the	O
overhead	O
is	O
a	O
number	O
that	O
can	O
be	O
stored	O
in	O
a	O
single	O
register	O
,	O
and	O
treating	O
it	O
as	O
O(1 )	O
is	O
like	O
treating	O
the	O
size	O
of	O
a	O
loop	O
counter	O
as	O
O(1 )	O
rather	O
than	O
log	O
of	O
the	O
number	O
of	O
iterations	O
.	O
</s>
<s>
It	O
is	O
used	O
by	O
the	B-Language
C	I-Language
standard	I-Language
libraries	I-Language
glibc	B-Language
,	O
newlib	B-Language
,	O
and	O
musl	B-Language
,	O
to	O
implement	O
the	O
memmem	O
and	O
strstr	O
family	O
of	O
substring	O
functions	O
.	O
</s>
