<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
longest	B-Data_Structure
common	I-Data_Structure
prefix	I-Data_Structure
array	I-Data_Structure
(	O
LCP	B-Data_Structure
array	I-Data_Structure
)	O
is	O
an	O
auxiliary	O
data	B-General_Concept
structure	I-General_Concept
to	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
It	O
stores	O
the	O
lengths	O
of	O
the	O
longest	O
common	O
prefixes	O
(	O
LCPs	O
)	O
between	O
all	O
pairs	O
of	O
consecutive	O
suffixes	O
in	O
a	O
sorted	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
For	O
example	O
,	O
if	O
A	O
:=	O
[	O
aab	O
,	O
ab	O
,	O
abaab	O
,	O
b	O
,	O
baab ]	O
is	O
a	O
suffix	B-Algorithm
array	I-Algorithm
,	O
the	O
longest	O
common	O
prefix	O
between	O
A[1]	O
=	O
aab	O
and	O
A[2]	O
=	O
ab	O
is	O
a	O
which	O
has	O
length	O
1	O
,	O
so	O
H[2]	O
=	O
1	O
in	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
H	O
.	O
Likewise	O
,	O
the	O
LCP	O
of	O
A[2]	O
=	O
ab	O
and	O
A[3]	O
=	O
abaab	O
is	O
ab	O
,	O
so	O
H[3]	O
=	O
2	O
.	O
</s>
<s>
Augmenting	O
the	O
suffix	B-Algorithm
array	I-Algorithm
with	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
allows	O
one	O
to	O
efficiently	O
simulate	O
top-down	O
and	O
bottom-up	O
traversals	B-Algorithm
of	O
the	O
suffix	B-Architecture
tree	I-Architecture
,	O
speeds	O
up	O
pattern	O
matching	O
on	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
is	O
a	O
prerequisite	O
for	O
compressed	O
suffix	B-Architecture
trees	I-Architecture
.	O
</s>
<s>
The	O
LCP	B-Data_Structure
array	I-Data_Structure
was	O
introduced	O
in	O
1993	O
,	O
by	O
Udi	O
Manber	O
and	O
Gene	O
Myers	O
alongside	O
the	O
suffix	B-Algorithm
array	I-Algorithm
in	O
order	O
to	O
improve	O
the	O
running	O
time	O
of	O
their	O
string	O
search	O
algorithm	O
.	O
</s>
<s>
Let	O
be	O
the	O
suffix	B-Algorithm
array	I-Algorithm
of	O
the	O
string	O
of	O
length	O
,	O
where	O
is	O
a	O
sentinel	O
letter	O
that	O
is	O
unique	O
and	O
lexicographically	O
smaller	O
than	O
any	O
other	O
character	O
.	O
</s>
<s>
Then	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
is	O
an	O
integer	O
array	B-Data_Structure
of	O
size	O
such	O
that	O
is	O
undefined	O
and	O
for	O
every	O
.	O
</s>
<s>
Thus	O
stores	O
the	O
length	O
of	O
longest	O
common	O
prefix	O
of	O
the	O
lexicographically	O
th	O
smallest	O
suffix	O
and	O
its	O
predecessor	O
in	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
Difference	O
between	O
LCP	B-Data_Structure
array	I-Data_Structure
and	O
suffix	B-Algorithm
array	I-Algorithm
:	O
</s>
<s>
Suffix	B-Algorithm
array	I-Algorithm
:	O
Represents	O
the	O
lexicographic	O
rank	O
of	O
each	O
suffix	O
of	O
an	O
array	B-Data_Structure
.	O
</s>
<s>
LCP	B-Data_Structure
array	I-Data_Structure
:	O
Contains	O
the	O
maximum	O
length	O
prefix	O
match	O
between	O
two	O
consecutive	O
suffixes	O
,	O
after	O
they	O
are	O
sorted	O
lexicographically	O
.	O
</s>
<s>
and	O
its	O
corresponding	O
sorted	O
suffix	B-Algorithm
array	I-Algorithm
:	O
</s>
<s>
Suffix	B-Algorithm
array	I-Algorithm
with	O
suffixes	O
written	O
out	O
underneath	O
vertically	O
:	O
</s>
<s>
Then	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
is	O
constructed	O
by	O
comparing	O
lexicographically	O
consecutive	O
suffixes	O
to	O
determine	O
their	O
longest	O
common	O
prefix	O
:	O
</s>
<s>
LCP	B-Data_Structure
array	I-Data_Structure
construction	O
algorithms	O
can	O
be	O
divided	O
into	O
two	O
different	O
categories	O
:	O
algorithms	O
that	O
compute	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
as	O
a	O
byproduct	O
to	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
algorithms	O
that	O
use	O
an	O
already	O
constructed	O
suffix	B-Algorithm
array	I-Algorithm
in	O
order	O
to	O
compute	O
the	O
LCP	O
values	O
.	O
</s>
<s>
provide	O
an	O
algorithm	O
to	O
compute	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
alongside	O
the	O
suffix	B-Algorithm
array	I-Algorithm
in	O
time	O
.	O
</s>
<s>
show	O
that	O
it	O
is	O
also	O
possible	O
to	O
modify	O
their	O
time	O
algorithm	O
such	O
that	O
it	O
computes	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
as	O
well	O
.	O
</s>
<s>
present	O
the	O
first	O
time	O
algorithm	O
(	O
FLAAP	O
)	O
that	O
computes	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
given	O
the	O
text	O
and	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
Assuming	O
that	O
each	O
text	O
symbol	O
takes	O
one	O
byte	O
and	O
each	O
entry	O
of	O
the	O
suffix	O
or	O
LCP	B-Data_Structure
array	I-Data_Structure
takes	O
4	O
bytes	O
,	O
the	O
major	O
drawback	O
of	O
their	O
algorithm	O
is	O
a	O
large	O
space	O
occupancy	O
of	O
bytes	O
,	O
while	O
the	O
original	O
output	O
(	O
text	O
,	O
suffix	B-Algorithm
array	I-Algorithm
,	O
LCP	B-Data_Structure
array	I-Data_Structure
)	O
only	O
occupies	O
bytes	O
.	O
</s>
<s>
Rather	O
than	O
the	O
actual	O
LCP	B-Data_Structure
array	I-Data_Structure
,	O
this	O
algorithm	O
builds	O
the	O
permuted	O
LCP	O
(	O
PLCP	O
)	O
array	B-Data_Structure
,	O
in	O
which	O
the	O
values	O
appear	O
in	O
text	O
order	O
rather	O
than	O
lexicographical	O
order	O
.	O
</s>
<s>
,	O
the	O
currently	O
fastest	O
linear-time	O
LCP	B-Data_Structure
array	I-Data_Structure
construction	O
algorithm	O
is	O
due	O
to	O
,	O
which	O
in	O
turn	O
is	O
based	O
on	O
one	O
of	O
the	O
fastest	O
suffix	B-Algorithm
array	I-Algorithm
construction	O
algorithms	O
(	O
SA-IS	O
)	O
by	O
.	O
</s>
<s>
As	O
noted	O
by	O
several	O
string	O
processing	O
problems	O
can	O
be	O
solved	O
by	O
the	O
following	O
kinds	O
of	O
tree	B-Algorithm
traversals	I-Algorithm
:	O
</s>
<s>
suffix	B-Architecture
tree	I-Architecture
traversal	O
using	O
the	O
suffix	O
links	O
.	O
</s>
<s>
show	O
how	O
to	O
simulate	O
a	O
bottom-up	O
traversal	O
of	O
the	O
suffix	B-Architecture
tree	I-Architecture
using	O
only	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
LCP	B-Data_Structure
array	I-Data_Structure
.	O
</s>
<s>
enhance	O
the	O
suffix	B-Algorithm
array	I-Algorithm
with	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
and	O
additional	O
data	B-General_Concept
structures	I-General_Concept
and	O
describe	O
how	O
this	O
enhanced	O
suffix	B-Algorithm
array	I-Algorithm
can	O
be	O
used	O
to	O
simulate	O
all	O
three	O
kinds	O
of	O
suffix	B-Architecture
tree	I-Architecture
traversals	B-Algorithm
.	O
</s>
<s>
reduce	O
the	O
space	O
requirements	O
of	O
the	O
enhanced	O
suffix	B-Algorithm
array	I-Algorithm
by	O
preprocessing	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
for	O
range	B-Algorithm
minimum	I-Algorithm
queries	I-Algorithm
.	O
</s>
<s>
Thus	O
,	O
every	O
problem	O
that	O
can	O
be	O
solved	O
by	O
suffix	B-Architecture
tree	I-Architecture
algorithms	O
can	O
also	O
be	O
solved	O
using	O
the	O
enhanced	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
Deciding	O
if	O
a	O
pattern	O
of	O
length	O
is	O
a	O
substring	O
of	O
a	O
string	O
of	O
length	O
takes	O
time	O
if	O
only	O
the	O
suffix	B-Algorithm
array	I-Algorithm
is	O
used	O
.	O
</s>
<s>
Thus	O
,	O
using	O
suffix	B-Algorithm
array	I-Algorithm
and	O
LCP	B-Data_Structure
array	I-Data_Structure
information	O
,	O
the	O
decision	O
query	O
can	O
be	O
answered	O
as	O
fast	O
as	O
using	O
the	O
suffix	B-Architecture
tree	I-Architecture
.	O
</s>
<s>
The	O
LCP	B-Data_Structure
array	I-Data_Structure
is	O
also	O
an	O
essential	O
part	O
of	O
compressed	O
suffix	B-Architecture
trees	I-Architecture
which	O
provide	O
full	O
suffix	B-Architecture
tree	I-Architecture
functionality	O
like	O
suffix	O
links	O
and	O
lowest	O
common	O
ancestor	O
queries	O
.	O
</s>
<s>
Furthermore	O
,	O
it	O
can	O
be	O
used	O
together	O
with	O
the	O
suffix	B-Algorithm
array	I-Algorithm
to	O
compute	O
the	O
Lempel-Ziv	B-Algorithm
LZ77	B-Algorithm
factorization	O
in	O
time	O
.	O
</s>
<s>
The	O
longest	O
repeated	O
substring	O
problem	O
for	O
a	O
string	O
of	O
length	O
can	O
be	O
solved	O
in	O
time	O
using	O
both	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
.	O
</s>
<s>
It	O
is	O
sufficient	O
to	O
perform	O
a	O
linear	O
scan	O
through	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
in	O
order	O
to	O
find	O
its	O
maximum	O
value	O
and	O
the	O
corresponding	O
index	O
where	O
is	O
stored	O
.	O
</s>
<s>
The	O
remainder	O
of	O
this	O
section	O
explains	O
two	O
applications	O
of	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
in	O
more	O
detail	O
:	O
How	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
of	O
a	O
string	O
can	O
be	O
used	O
to	O
construct	O
the	O
corresponding	O
suffix	B-Architecture
tree	I-Architecture
and	O
how	O
it	O
is	O
possible	O
to	O
answer	O
LCP	O
queries	O
for	O
arbitrary	O
suffixes	O
using	O
range	B-Algorithm
minimum	I-Algorithm
queries	I-Algorithm
on	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
.	O
</s>
<s>
We	O
use	O
binary	O
search	O
against	O
the	O
suffix	B-Algorithm
array	I-Algorithm
of	O
to	O
find	O
the	O
starting	O
and	O
end	O
position	O
of	O
all	O
occurrences	O
of	O
.	O
</s>
<s>
Now	O
to	O
speed	O
up	O
the	O
search	O
,	O
we	O
use	O
LCP	B-Data_Structure
array	I-Data_Structure
,	O
specifically	O
a	O
special	O
version	O
of	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
(	O
LCP-LR	O
below	O
)	O
.	O
</s>
<s>
The	O
issue	O
with	O
using	O
standard	O
binary	O
search	O
(	O
without	O
the	O
LCP	O
information	O
)	O
is	O
that	O
in	O
each	O
of	O
the	O
comparisons	O
needed	O
to	O
be	O
made	O
,	O
we	O
compare	O
P	O
to	O
the	O
current	O
entry	O
of	O
the	O
suffix	B-Algorithm
array	I-Algorithm
,	O
which	O
means	O
a	O
full	O
string	O
comparison	O
of	O
up	O
to	O
m	O
characters	O
.	O
</s>
<s>
The	O
LCP-LR	O
array	B-Data_Structure
helps	O
improve	O
this	O
to	O
,	O
in	O
the	O
following	O
way	O
:	O
</s>
<s>
At	O
any	O
point	O
during	O
the	O
binary	O
search	O
algorithm	O
,	O
we	O
consider	O
,	O
as	O
usual	O
,	O
a	O
range	O
of	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
its	O
central	O
point	O
,	O
and	O
decide	O
whether	O
we	O
continue	O
our	O
search	O
in	O
the	O
left	O
sub-range	O
or	O
in	O
the	O
right	O
sub-range	O
.	O
</s>
<s>
We	O
still	O
need	O
to	O
precompute	O
LCP-LR	O
so	O
it	O
is	O
able	O
to	O
tell	O
us	O
in	O
time	O
the	O
lcp	O
between	O
any	O
two	O
entries	O
of	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
We	O
know	O
the	O
standard	O
LCP	B-Data_Structure
array	I-Data_Structure
gives	O
us	O
the	O
lcp	O
of	O
consecutive	O
entries	O
only	O
,	O
i.e.	O
</s>
<s>
Another	O
way	O
of	O
looking	O
at	O
it	O
is	O
:	O
every	O
entry	O
of	O
the	O
suffix	B-Algorithm
array	I-Algorithm
occurs	O
as	O
central	O
point	O
of	O
exactly	O
one	O
possible	O
range	O
during	O
binary	O
search	O
.	O
</s>
<s>
Moreover	O
,	O
there	O
is	O
a	O
straightforward	O
recursive	O
algorithm	O
to	O
compute	O
the	O
values	O
of	O
LCP-LR	O
in	O
time	O
from	O
the	O
standard	O
LCP	B-Data_Structure
array	I-Data_Structure
.	O
</s>
<s>
Given	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
the	O
LCP	B-Data_Structure
array	I-Data_Structure
of	O
a	O
string	O
of	O
length	O
,	O
its	O
suffix	B-Architecture
tree	I-Architecture
can	O
be	O
constructed	O
in	O
time	O
based	O
on	O
the	O
following	O
idea	O
:	O
Start	O
with	O
the	O
partial	O
suffix	B-Architecture
tree	I-Architecture
for	O
the	O
lexicographically	O
smallest	O
suffix	O
and	O
repeatedly	O
insert	O
the	O
other	O
suffixes	O
in	O
the	O
order	O
given	O
by	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
Let	O
be	O
the	O
partial	O
suffix	B-Architecture
tree	I-Architecture
for	O
.	O
</s>
<s>
This	O
creates	O
the	O
partial	O
suffix	B-Architecture
tree	I-Architecture
.	O
</s>
<s>
This	O
creates	O
the	O
partial	O
suffix	B-Architecture
tree	I-Architecture
.	O
</s>
<s>
The	O
LCP	B-Data_Structure
array	I-Data_Structure
only	O
contains	O
the	O
length	O
of	O
the	O
longest	O
common	O
prefix	O
of	O
every	O
pair	O
of	O
consecutive	O
suffixes	O
in	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
However	O
,	O
with	O
the	O
help	O
of	O
the	O
inverse	O
suffix	B-Algorithm
array	I-Algorithm
(	O
,	O
i.e.	O
</s>
<s>
the	O
suffix	O
that	O
starts	O
at	O
position	O
in	O
is	O
stored	O
in	O
position	O
in	O
)	O
and	O
constant-time	O
range	B-Algorithm
minimum	I-Algorithm
queries	I-Algorithm
on	O
,	O
it	O
is	O
possible	O
to	O
determine	O
the	O
length	O
of	O
the	O
longest	O
common	O
prefix	O
of	O
arbitrary	O
suffixes	O
in	O
time	O
.	O
</s>
<s>
Because	O
of	O
the	O
lexicographic	O
order	O
of	O
the	O
suffix	B-Algorithm
array	I-Algorithm
,	O
every	O
common	O
prefix	O
of	O
the	O
suffixes	O
and	O
has	O
to	O
be	O
a	O
common	O
prefix	O
of	O
all	O
suffixes	O
between	O
'	O
s	O
position	O
in	O
the	O
suffix	B-Algorithm
array	I-Algorithm
and	O
'	O
s	O
position	O
in	O
the	O
suffix	B-Algorithm
array	I-Algorithm
.	O
</s>
<s>
This	O
value	O
can	O
be	O
found	O
in	O
constant	O
time	O
if	O
is	O
preprocessed	O
for	O
range	B-Algorithm
minimum	I-Algorithm
queries	I-Algorithm
.	O
</s>
