Skip to main content
QUICK REVIEW

[论文解读] Fast Longest Common Extensions in Small Space

Alberto Policriti, Nicola Prezza|arXiv (Cornell University)|Jul 22, 2016
Algorithms and Data Compression参考文献 10被引用 3
一句话总结

本文提出两种新颖且空间高效的LCE(最长公共扩展)问题数据结构,采用梅森素数和一般素数模数的Karp-Rabin指纹技术。第一种结构仅使用 $n\lceil\log_2\sigma\rceil$ 位——等同于文本大小——以高概率支持 $\mathcal{O}(\log \ell)$ 时间复杂度的LCE查询,在最优空间内实现亚线性查询时间,同时两种结构均支持快速子串提取,且构建时间均为 $\mathcal{O}(n)$。

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\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.

研究动机与目标

  • 设计一种LCE问题的数据结构,仅使用原始文本的空间,同时实现亚线性查询时间。
  • 利用梅森素数在Karp-Rabin指纹中的性质,实现最优空间使用和快速查询性能。
  • 将该方法推广至任意素数模数,且不增加空间使用或降低查询效率,仅增加少量附加空间。
  • 在空间、查询时间和预处理时间方面优于现有的蒙特卡洛和确定性LCE解决方案。
  • 实现并评估所提结构在大规模文本(如人类基因组)上的实际效率和性能。

提出的方法

  • 使用模数为梅森素数 $q = 2^p - 1$ 的Karp-Rabin指纹技术,通过哈希值的二分查找实现高效的子串比较和LCE计算。
  • 预先计算并存储模 $q$ 下的 $2^{2^i}$ 值,记为 $z_i = 2^{2^i} \mod q$,以在二分查找过程中实现常数时间的哈希比较。
  • 应用指数查找,将二分查找的区间从 $\mathcal{O}(n)$ 缩小至 $\mathcal{O}(\ell)$,从而改善平均情况下的查询时间。
  • 对于一般素数模数,通过增加 $n/w + w\log_2 n$ 位额外空间,支持最坏情况下的 $\mathcal{O}(\log \ell)$ LCE查询和 $\mathcal{O}(m\log\sigma/w)$ 时间复杂度的子串提取。
  • 通过线性扫描计算前缀指纹和采样必要值,在 $\mathcal{O}(n)$ 时间内构建数据结构。
  • 基于预计算的 $z_i$ 值设计采样策略,实现在二分查找过程中对子串的常数时间比较。

实验结果

研究问题

  • RQ1是否可以在仅使用 $\mathcal{O}(1)$ 个额外字词空间(除文本外)的前提下,实现 $o(n)$ 时间复杂度的LCE查询?
  • RQ2在Karp-Rabin指纹中使用梅森素数是否能够实现最优空间使用和亚线性查询时间?
  • RQ3是否可能仅使用 $n\lceil\log_2\sigma\rceil$ 位空间,以高概率实现 $\mathcal{O}(\log \ell)$ 时间复杂度的LCE查询?
  • RQ4该方法能否推广至任意素数模数,且不带来显著的空间或时间开销?
  • RQ5所提结构的实际性能与现有实现相比如何,特别是在速度、内存使用和构建时间方面?

主要发现

  • 第一种数据结构仅使用 $n\lceil\log_2\sigma\rceil$ 位空间——等同于存储文本本身——并以高概率支持 $\mathcal{O}(\log \ell)$ 时间复杂度的LCE查询,这是首次在最优空间内实现 $o(n)$ 查询时间的成果。
  • 基于梅森素数的C++实现,在30亿字符的人类基因组前缀上,LCE查询平均耗时710纳秒,单字符访问耗时160纳秒,额外空间仅增加560字节(相对于2位/字符的存储)。
  • 该结构在标准计算机上构建耗时170秒,验证了其最优的 $\mathcal{O}(n)$ 预处理时间。
  • 第二种结构在 $n\lceil\log_2\sigma\rceil + n/w + w\log_2 n$ 位空间内,支持最坏情况下的 $\mathcal{O}(\log \ell)$ LCE查询和 $\mathcal{O}(m\log\sigma/w)$ 时间复杂度的子串提取,相较于先前的蒙特卡洛解决方案在空间和时间上均有改进。
  • 该实现的LCE查询速度比直接内存访问快10倍,同时仅使用极少量额外空间,证明了其高度实用性。
  • 结果表明,在最优空间内实现 $o(n)$ 时间复杂度的LCE查询是可行的,且使用梅森素数可同时实现理论最优性和实际高效性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。