[Paper Review] Fast Longest Common Extensions in Small Space
This paper presents two novel, space-efficient data structures for the Longest Common Extension (LCE) problem using Karp-Rabin fingerprinting with Mersenne primes and general prime moduli. The first structure uses only $n\lceil\log_2\sigma\rceil$ bits—equivalent to the text size—and supports $\mathcal{O}(\log \ell)$-time LCE queries with high probability, achieving sublinear query time in optimal space, while both structures support fast substring extraction and are built in $\mathcal{O}(n)$ time.
In this paper we address the longest common extension (LCE) problem: to compute the length $\ell$ of the longest common prefix between any two suffixes of $T\in Σ^n$ with $ Σ= \{0, \ldots σ-1\} $. We present two fast and space-efficient solutions based on (Karp-Rabin) extit{fingerprinting} and extit{sampling}. Our first data structure exploits properties of Mersenne prime numbers when used as moduli of the Karp-Rabin hash function and takes $n\lceil \log_2σ ceil$ bits of space. Our second structure works with any prime modulus and takes $n\lceil \log_2σ ceil + n/w + w\log_2 n$ bits of space ($ w $ memory-word size). Both structures support $\mathcal O\left(m\logσ/w ight)$-time extraction of any length-$m$ text substring, $\mathcal O(\log\ell)$-time LCE queries with high probability, and can be built in optimal $\mathcal O(n)$ time. In the first case, ours is the first result showing that it is possible to answer LCE queries in $o(n)$ time while using only $\mathcal O(1)$ words on top of the space required to store the text. Our results improve the state of the art in space usage, query times, and preprocessing times and are extremely practical: we present a C++ implementation that is very fast and space-efficient in practice.
Motivation & Objective
- To design a data structure for the LCE problem that uses only the space of the original text while enabling sublinear query time.
- To leverage properties of Mersenne prime numbers in Karp-Rabin fingerprinting to achieve optimal space and fast query performance.
- To extend the approach to work with arbitrary prime moduli without sacrificing query efficiency or increasing space usage beyond a small additive term.
- To improve upon existing Monte Carlo and deterministic LCE solutions in terms of space, query time, and preprocessing time.
- To implement and evaluate the proposed structures for practical efficiency and performance on large-scale texts like the human genome.
Proposed method
- Use Karp-Rabin fingerprinting with a Mersenne prime modulus $q = 2^p - 1$ to enable efficient substring comparison and LCE computation via binary search on hash values.
- Precompute and store powers of 2 modulo $q$ as $z_i = 2^{2^i} \mod q$ to support constant-time hash comparisons during binary search.
- Apply exponential search to reduce the binary search interval from $\mathcal{O}(n)$ to $\mathcal{O}(\ell)$, improving average-case query time.
- For general prime moduli, augment the structure with $n/w + w\log_2 n$ additional bits to support worst-case $\mathcal{O}(\log \ell)$ LCE queries and $\mathcal{O}(m\log\sigma/w)$ substring extraction.
- Construct the data structure in $\mathcal{O}(n)$ time by computing prefix fingerprints and sampling necessary values in linear passes.
- Use a sampling strategy based on precomputed $z_i$ values to enable constant-time comparison of substrings during binary search.
Experimental results
Research questions
- RQ1Can LCE queries be answered in $o(n)$ time while using only $\mathcal{O}(1)$ words of additional space beyond the text?
- RQ2Can the use of Mersenne primes in Karp-Rabin fingerprinting enable optimal space usage and sublinear query time for LCE queries?
- RQ3Is it possible to achieve $\mathcal{O}(\log \ell)$-time LCE queries with high probability using only $n\lceil\log_2\sigma\rceil$ bits of space?
- RQ4Can the approach be generalized to work with arbitrary prime moduli without significant space or time overhead?
- RQ5How does the practical performance of the proposed structure compare to existing implementations in terms of speed, memory usage, and build time?
Key findings
- The first data structure uses only $n\lceil\log_2\sigma\rceil$ bits of space—equivalent to storing the text—and supports $\mathcal{O}(\log \ell)$-time LCE queries with high probability, marking the first such result achieving $o(n)$ query time in optimal space.
- The C++ implementation of the Mersenne prime-based structure achieves an average of 710 ns per LCE query and 160 ns per single-character access on a 3-billion-character human genome prefix, using only 560 bytes above the 2-bit-per-character storage.
- The structure is built in 170 seconds on a standard machine, demonstrating optimal $\mathcal{O}(n)$ preprocessing time.
- The second structure supports worst-case $\mathcal{O}(\log \ell)$ LCE queries and $\mathcal{O}(m\log\sigma/w)$ substring extraction in $n\lceil\log_2\sigma\rceil + n/w + w\log_2 n$ bits, improving on prior Monte Carlo solutions in space and time.
- The implementation outperforms direct memory access in speed for LCE queries (10x slowdown) while using minimal additional space, proving high practicality.
- The results show that $o(n)$-time LCE queries are feasible in optimal space, and the use of Mersenne primes enables both theoretical optimality and practical efficiency.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.