English

Fast Longest Common Extensions in Small Space

Data Structures and Algorithms 2016-07-25 v1

Abstract

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ΣnT\in \Sigma^n with Σ={0,σ1} \Sigma = \{0, \ldots \sigma-1\} . We present two fast and space-efficient solutions based on (Karp-Rabin) \textit{fingerprinting} and \textit{sampling}. Our first data structure exploits properties of Mersenne prime numbers when used as moduli of the Karp-Rabin hash function and takes nlog2σn\lceil \log_2\sigma\rceil bits of space. Our second structure works with any prime modulus and takes nlog2σ+n/w+wlog2nn\lceil \log_2\sigma\rceil + n/w + w\log_2 n bits of space (w w memory-word size). Both structures support O(mlogσ/w)\mathcal O\left(m\log\sigma/w \right)-time extraction of any length-mm text substring, O(log)\mathcal O(\log\ell)-time LCE queries with high probability, and can be built in optimal O(n)\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)o(n) time while using only O(1)\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.

Keywords

Cite

@article{arxiv.1607.06660,
  title  = {Fast Longest Common Extensions in Small Space},
  author = {Alberto Policriti and Nicola Prezza},
  journal= {arXiv preprint arXiv:1607.06660},
  year   = {2016}
}
R2 v1 2026-06-22T15:01:37.791Z