<s>
The	O
bitap	B-Algorithm
algorithm	I-Algorithm
(	O
also	O
known	O
as	O
the	O
shift-or	B-Algorithm
,	O
shift-and	B-Algorithm
or	O
Baeza-Yates	O
–	O
Gonnet	O
algorithm	O
)	O
is	O
an	O
approximate	B-Algorithm
string	I-Algorithm
matching	I-Algorithm
algorithm	O
.	O
</s>
<s>
The	O
bitap	B-Algorithm
algorithm	I-Algorithm
is	O
perhaps	O
best	O
known	O
as	O
one	O
of	O
the	O
underlying	O
algorithms	O
of	O
the	O
Unix	B-Application
utility	B-Application
agrep	B-Device
,	O
written	O
by	O
Udi	O
Manber	O
,	O
Sun	O
Wu	O
,	O
and	O
Burra	O
Gopal	O
.	O
</s>
<s>
Manber	O
and	O
Wu	O
's	O
original	O
paper	O
gives	O
extensions	O
of	O
the	O
algorithm	O
to	O
deal	O
with	O
fuzzy	B-Application
matching	I-Application
of	O
general	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
The	O
bitap	B-Algorithm
algorithm	I-Algorithm
for	O
exact	O
string	B-Algorithm
searching	I-Algorithm
was	O
invented	O
by	O
Bálint	O
Dömölki	O
in	O
1964	O
and	O
extended	O
by	O
R	O
.	O
K	O
.	O
Shyamasundar	O
in	O
1977	O
,	O
before	O
being	O
reinvented	O
by	O
Ricardo	O
Baeza-Yates	O
and	O
Gaston	O
Gonnet	O
in	O
1989	O
(	O
one	O
chapter	O
of	O
first	O
author	O
's	O
PhD	O
thesis	O
)	O
which	O
also	O
extended	O
it	O
to	O
handle	O
classes	O
of	O
characters	O
,	O
wildcards	O
,	O
and	O
mismatches	O
.	O
</s>
<s>
In	O
1991	O
,	O
it	O
was	O
extended	O
by	O
Manber	O
and	O
Wu	O
to	O
handle	O
also	O
insertions	O
and	O
deletions	O
(	O
full	O
fuzzy	B-Algorithm
string	I-Algorithm
searching	I-Algorithm
)	O
.	O
</s>
<s>
The	O
bitap	B-Algorithm
algorithm	I-Algorithm
for	O
exact	O
string	B-Algorithm
searching	I-Algorithm
,	O
in	O
full	O
generality	O
,	O
looks	O
like	O
this	O
in	O
pseudocode	O
:	O
</s>
<s>
Bitap	B-Algorithm
distinguishes	O
itself	O
from	O
other	O
well-known	O
string	B-Algorithm
searching	I-Algorithm
algorithms	I-Algorithm
in	O
its	O
natural	O
mapping	O
onto	O
simple	O
bitwise	O
operations	O
,	O
as	O
in	O
the	O
following	O
modification	O
of	O
the	O
above	O
program	O
.	O
</s>
<s>
Therefore	O
,	O
the	O
bitap	B-Algorithm
algorithm	I-Algorithm
performs	O
better	O
when	O
applied	O
to	O
inputs	O
over	O
smaller	O
alphabets	O
.	O
</s>
<s>
To	O
perform	O
fuzzy	B-Algorithm
string	I-Algorithm
searching	I-Algorithm
using	O
the	O
bitap	B-Algorithm
algorithm	I-Algorithm
,	O
it	O
is	O
necessary	O
to	O
extend	O
the	O
bit	O
array	O
R	O
into	O
a	O
second	O
dimension	O
.	O
</s>
<s>
The	O
implementation	O
below	O
performs	O
fuzzy	B-Application
matching	I-Application
(	O
returning	O
the	O
first	O
match	O
with	O
up	O
to	O
k	O
errors	O
)	O
using	O
the	O
fuzzy	O
bitap	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
