diff --git a/06-hash/hash.tex b/06-hash/hash.tex index 5c2ecdab338720466967f4831dd0ff86d0f1261e..b17277b261b789058f3e80895bf7bfaee171a2cf 100644 --- a/06-hash/hash.tex +++ b/06-hash/hash.tex @@ -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 diff --git a/08-string/string.tex b/08-string/string.tex index c115c81f132780fde01f66d2a86661df380c57de..a2ccb5e10d6a2717d27d4054864290515ee70863 100644 --- a/08-string/string.tex +++ b/08-string/string.tex @@ -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. }