Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
ds2-notes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
datovky
ds2-notes
Commits
f54ac383
Commit
f54ac383
authored
5 years ago
by
Martin Mareš
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitlab.kam.mff.cuni.cz:mj/dsbook
parents
662317bf
4fcd9912
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
06-hash/hash.tex
+4
-0
4 additions, 0 deletions
06-hash/hash.tex
08-string/string.tex
+5
-2
5 additions, 2 deletions
08-string/string.tex
with
9 additions
and
2 deletions
06-hash/hash.tex
+
4
−
0
View file @
f54ac383
...
...
@@ -635,6 +635,10 @@ $f$,~$g$ chosen at random from a~$\lceil 6\log n\rceil$-independent family.
Then the expected time complexity of
\alg
{
Insert
}
is
$
\O
(
1
)
$
.
}
\note
{
Setting the timeout to
$
\lceil
6
\log
m
\rceil
$
also works.
}
\note
{
It is also known that a~6-independent family is not sufficient to guarantee
expected constant insertion time, while tabulation hashing (even though
...
...
This diff is collapsed.
Click to expand it.
08-string/string.tex
+
5
−
2
View file @
f54ac383
...
...
@@ -96,13 +96,16 @@ where $\LCP(\gamma,\delta)$ is the maximum~$k$ such that $\gamma[{}:k] = \delta[
\obs
{
The LCP array can be easily used to find the longest common prefix of any two
suffixes
$
\alpha
[
i:
{}
]
$
and
$
\alpha
[
j:
{}
]
$
. We use the rank array to locate them
in the lexicographic order of all suffixes: they lie at positions
$
i'
=
R
[
i
]
$
and
$
j'
=
R
[
j
]
$
. Then we compute
$
k
=
\min
(
L
[
i'
]
, L
[
i'
+
1
]
,
\ldots
, L
[
j'
-
1
])
$
.
$
i'
=
R
[
i
]
$
and
$
j'
=
R
[
j
]
$
(w.l.o.g.
$
i' < j'
$
).
Then we compute
$
k
=
\min
(
L
[
i'
]
, L
[
i'
+
1
]
,
\ldots
, L
[
j'
-
1
])
$
.
We claim that
$
\LCP
(
\alpha
[
i:
{}
]
,
\alpha
[
j:
{}
])
$
is exactly~
$
k
$
.
First, each pair of adjacent suffixes in the range
$
[
i',j'
]
$
has a~common prefix of
length at least~
$
k
$
, so our LCP is at least~
$
k
$
. However, it cannot be more:
we have
$
k
=
L
[
\ell
]
$
for some~
$
\ell
\in
[
i',j'
-
1
]
$
, so the
$
\ell
$
-th and
$
(
\ell
+
1
)
$
-th suffix
differ at position
$
k
+
1
$
. Since all suffixes in the range share the first~
$
k
$
characters,
differ at position
$
k
+
1
$
(or one of the suffixes ends at position~
$
k
$
, but we can simply
imagine a~padding character at the end, ordered before all ordinary characters.)
Since all suffixes in the range share the first~
$
k
$
characters,
their
$
(
k
+
1
)
$
-th characters must be non-decreasing. This means that the
$
(
k
+
1
)
$
-th character
of the first and the last suffix in the range must differ, too.
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment