In the $k$-Edit Circular Pattern Matching ($k$-Edit CPM) problem, we are given a length-$n$ text $T$, a length-$m$ pattern $P$, and a positive integer threshold $k$, and we are to report all starting positions of the substrings of $T$ that are at edit distance at most $k$ from some cyclic rotation of $P$. In the decision version of the problem, we are to check if any such substring exists. Very recently, Charalampopoulos et al. [ESA 2022] presented $O(nk^2)$-time and $O(nk \log^3 k)$-time solutions for the reporting and decision versions of $k$-Edit CPM, respectively. Here, we show that the reporting and decision versions of $k$-Edit CPM can be solved in $O(n+(n/m) k^6)$ time and $O(n+(n/m) k^5 \log^3 k)$ time, respectively, thus obtaining the first algorithms with a complexity of the type $O(n+(n/m) \mathrm{poly}(k))$ for this problem. Notably, our algorithms run in $O(n)$ time when $m=\Omega(k^6)$ and are superior to the previous respective solutions when $m=\omega(k^4)$. We provide a meta-algorithm that yields efficient algorithms in several other interesting settings, such as when the strings are given in a compressed form (as straight-line programs), when the strings are dynamic, or when we have a quantum computer. We obtain our solutions by exploiting the structure of approximate circular occurrences of $P$ in $T$, when $T$ is relatively short w.r.t. $P$. Roughly speaking, either the starting positions of approximate occurrences of rotations of $P$ form $O(k^4)$ intervals that can be computed efficiently, or some rotation of $P$ is almost periodic (is at a small edit distance from a string with small period). Dealing with the almost periodic case is the most technically demanding part of this work; we tackle it using properties of locked fragments (originating from [Cole and Hariharan, SICOMP 2002]).
翻译:在$k$-编辑循环模式匹配($k$-Edit CPM)问题中,给定长度为$n$的文本$T$、长度为$m$的模式$P$以及正整数阈值$k$,我们需要报告$T$中所有与$P$的某个循环旋转编辑距离不超过$k$的子串的起始位置。问题的判定版本要求检查是否存在这样的子串。最近,Charalampopoulos等人[ESA 2022]针对$k$-Edit CPM的报告版本和判定版本分别提出了时间复杂度为$O(nk^2)$和$O(nk \log^3 k)$的算法。本文证明,$k$-Edit CPM的报告版本和判定版本可分别在$O(n+(n/m) k^6)$和$O(n+(n/m) k^5 \log^3 k)$时间内求解,从而为此问题首次提供了复杂度为$O(n+(n/m) \mathrm{poly}(k))$形式的算法。值得注意的是,当$m=\Omega(k^6)$时,我们的算法在$O(n)$时间内运行,并在$m=\omega(k^4)$时优于先前提出的解决方案。我们提供了一种元算法,该算法在多种其他重要场景中同样高效,例如字符串以压缩形式(直线程序)给出、字符串动态变化或使用量子计算机时。我们的解决方案通过利用$P$在$T$中近似循环出现的结构特性(当$T$相对于$P$较短时)得出。大致而言,要么$P$的旋转近似出现的起始位置形成$O(k^4)$个可高效计算的区间,要么$P$的某个旋转近乎周期(与具有小周期的字符串的编辑距离很小)。处理近周期情形是本文技术难度最大的部分;我们利用锁定片段(源自[Cole and Hariharan, SICOMP 2002])的性质对此进行解决。