6.851:
Advanced
Data
Structures
Spring
2010
Lecture
8
—
March
2,
2010
Prof.
Erik
Demaine
1
Overview
In
the
last
lecture
we
studied
suﬃx
trees
and
suﬃx
arrays.
These
two
data
structures
are
useful
for
answering
a
variety
of
queries
on
strings
such
as
string
matching,
string
frequency
and
longest
repeating
substring.
They
offer
advantages
over
more
generic
data
structures
like
binary
search
trees
and
hashes.
We
learned
that
a
lineartime
algorithm
exists
for
converting
between
suﬃx
trees
and
suﬃx
arrays,
and
that
there
exists
an
algorithm
for
eﬃciently
constructing
suﬃx
arrays,
the
DC3
algorithm.
Finally,
we
studied
a
modification
to
suﬃx
arrays
that
allows
one
to
perform
document
retrieval
queries
in
O
(

P

+
d
)
time,
where
P
is
the
pattern
to
search
a
set
of
documents
for
and
d
is
the
number
of
documents
containing
P
.
In
today’s
lecture
two
problems
are
discussed:
Level
Ancestor
Query
(LAQ)
and
Least
Common
Ancestor
(LCA).
LAQ
will
be
covered
fully
today,
while
LCA
will
be
completed
next
lecture.
Both
problems
have
the
same
setting:
given
a
rooted
tree
T
and
a
node
v
,
find
an
ancestor
of
v
with
some
property.
For
LAQ,
we
will
study
various
approaches
with
different
preprocessing
and
query
times,
culminating
in
a
data
structure
with
O
(
n
)
preprocessing
and
O
(1)
query
time.
For
LCA,
we
will
study
a
different
but
related
problem
(Range
Minimum
Query
or
RMQ)
which
will
help
us
to
solve
LCA.
2
Least
Ancestor
Queries
(LAQ)
First
we
introduce
notation.
Let
h
(
v
)
be
the
height
of
a
node
v
in
a
tree.
Given
a
node
v
and
level
l
,
LAQ
(
v, l
)
is
the
ancestor
a
of
v
such
that
h
(
a
)
−
h
(
v
) =
l
.
Today
we
will
study
a
variety
of
data
structures
with
various
preprocessing
and
query
times
which
answer
LAQ
(
v, l
)
queries.
For
a
data
structure
which
requires
f
(
n
)
query
time
and
g
(
n
)
preprocessing
time,
we
will
denote
its
running
time
as
�
g
(
n
)
, f
(
n
)
�
.
The
following
algorithms
are
taken
from
the
set
found
in
a
paper
from
Bender
and
FarachColton[1].
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '10
 ErikDemaine
 Graph Theory, Data Structures, Big O notation, Tree structure

Click to edit the document details