Tighter Bounds and Optimal Algorithms for All Maximal α-gapped Repeats and Palindromes
Paweł Gawrychowski, I Tomohiro, Shunsuke Inenaga, Dominik Köppl, Florín Manea · Theory of Computing Systems · 2017
An α-gapped repeat (α ≥ 1) in a word w is a factor uvu of w such that |u v| ≤ α|u|; the two occurrences of u are called arms of this α-gapped repeat. An α-gapped repeat is called maximal if its arms cannot be extended simultaneously with the same character to the right nor to the left. We show that the number of all maximal α-gapped repeats occurring in words of length n is upper bounded by 18α n. In the case of α-gapped palindromes, i.e., factors $uv{{u}^{\intercal }}$ with |u v|≤ α|u|, we show that the number of all maximal α-gapped palindromes occurring in words of length n is upper bounded by 28α n + 7n. Both upper bounds allow us to construct algorithms finding all maximal α-gapped repeats and/or all maximal α-gapped palindromes of a word of length n on an integer alphabet of size $n^{\mathcal {O}(1)}$ in ${\mathcal {O}(\alpha n)}$ time. The presented running times are optimal since there are words that have Θ(α n) maximal α-gapped repeats/palindromes.