Longest Common Extensions with Wildcards: Trade-off and Applications
Gabriel Bathie, Itai Boneh, Panagiotis Charalampopoulos, Jonas Ellert, Tatiana Starikovskaya
备注:
Extended version of a work that was presented at ESA 2024. This version contains extra (conditional) lower bounds. Abstract abridged to meet arXiv requirements
We study the Longest Common Extension (LCE) problem in a string containing wildcards. Wildcards (also called "don't cares" or "holes") are special characters that match any other character in the alphabet, similar to the character "?" in Unix commands or "." in regular expression engines.
We consider the problem parametrized by $G$, the number of maximal contiguous groups of wildcards in the input string. Our main contribution is a simple data structure for this problem that can be built in $O(n (G/t) \log n)$ time, occupies $O(nG/t)$ space, and answers queries in $O(t)$ time, for any $t \in [1, G]$. Up to the $O(\log n)$ factor, this interpolates smoothly between the data structure of Crochemore et al. [JDA 2015], which has $O(nG)$ preprocessing time and space, and $O(1)$ query time, and a simple solution based on the "kangaroo jumping" technique [Landau and Vishkin, STOC 1986], which has $O(n)$ preprocessing time and space, and $O(G)$ query time.
By establishing a connection between this problem and Boolean matrix multiplication, we show that our solution is optimal, up to subpolynomial factors, among combinatorial data structures when $G = Ω(n^ε)$ under a widely believed hypothesis. In addition, we develop a simple deterministic combinatorial algorithm for sparse Boolean matrix multiplication. We further establish a conditional lower bound for non-combinatorial data structures, stating that $O(nG/t^4)$ preprocessing time (resp. space) is optimal, up to subpolynomial factors, for any data structure with query time $t$ for a wide range of $t$ and $G$, assuming the well-established $\textsf{3SUM}$ (resp. $\textsf{Set-Disjointness}$) conjecture.
Finally, we show that our data structure can be used to obtain efficient algorithms for approximate pattern matching and structural analysis of strings with wildcards.
Time-Space Tradeoffs for Finding a Long Common Substring
我们考虑的问题,找到两个文件的总长度$n$,最长的字符串作为两个文件的子串。这个问题被称为最长公共子串(LCS)问题,有一个经典的$O(n)$时间解决方案,可以追溯到后缀树的发现(Weiner,1973)和整数字母表的有效构造(Farach-Colton,1997)。然而,这些解决方案需要$Θ(n)$空间,这在许多应用中是禁止的。为了解决这个问题,Starikovskaya和Vildhøj(CPM 2013)表明,对于$n^{2/3} \le s \le n^{1-o(1)}$,LCS问题可以在$O(s)$空间和$O(\frac{n^2}{s})$时间中求解。Kociumaka等人(欧空局,2014年)将这一权衡推广到$1 \leq s \leq n$,从而提供了从恒定空间到线性空间的平滑时空权衡。在本文中,我们获得了显着的加速的情况下,所寻求的LCS的长度$L$是大的。对于$1 \leq s \leq n$,我们证明了LCS问题可以在$O(s)$空间和$\tilde{O}(\frac{n^2}{L\cdot s}+n)$时间中求解。该结果基于源自具有失配问题的LCS的技术(Flouri等人,2015; Charalampopoulos等人,CPM 2018),空间高效的局部一致性解析(Birenzwige et al.,SODA 2020),以及输入文档中最大重复(运行)的结构。
字符串中两个索引的最长公共扩展(LCE)是从这两个索引开始的最长相同子串的长度。LCE问题要求将字符串预处理为支持快速LCE查询的紧凑数据结构。在本文中,我们推广的LCE问题的树,并提出了一些应用LCE树尝试和XML数据库。给定一个大小为$n$的带标签和有根树$T$,目标是将$T$预处理成一个紧凑的数据结构,该结构支持$T$中的子路径和子树之间的以下LCE查询。假设$v_1$、$v_2$、$w_1$和$w_2$是$T$的节点,使得$w_1$和$w_2$分别是$v_1$和$v_2$的后代。\begin{itemize} \item $\LCEPP(v_1, w_1, v_2, w_2)$: (path-path $\LCE$) return the longest common prefix of the paths $v_1 \leadsto w_1$ and $v_2 \leadsto w_2$. \item $\LCEPT(v_1, w_1, v_2)$: (path-tree $\LCE$) return maximal path-path LCE of the path $v_1 \leadsto w_1$ and any path from $v_2$ to a descendant leaf. \item $\LCETT(v_1, v_2)$: (tree-tree $…