Palindromes are non-empty strings that read the same forward and backward. The problem of recognizing strings that can be represented as the concatenation of even-length palindromes, the concatenation of palindromes of length greater than one, and the concatenation of exactly $k$ palindromes was introduced in the seminal paper of Knuth, Morris, and Pratt [SIAM J. Comput., 1977]. In this work, we study the problem of recognizing so-called $k$-palindromic strings, which can be represented as the concatenation of exactly $k$ palindromes. It was shown that the problem is solvable in linear space and time [Rubinchik and Schur, MFCS'2020]. We aim to develop a sublinear-space solution, and show the following results: (1) First, we show a structural characterization of the set of all $k$-palindromic prefixes of a string by representing it as a union of a small number of highly structured string sets, called affine prefix sets. We show that the size of this representation is of the right asymptotic form by constructing an almost matching lower bound. (2) Secondly, we derive a read-only algorithm that, given a string $T$ of length $n$ and an integer $k$, computes a compact representation of the $i$-palindromic prefixes of $T$, for all $1 \le i \le k$. (3) Finally, we also give a read-only algorithm for computing the palindromic length of $T$, which is the smallest $\ell$ such that $T$ is $\ell$-palindromic, given that $\ell \le k$. The algorithms use $\mathcal O(n \cdot 6^{k^2} \cdot \log^k n)$ time and $\mathcal O(6^{k^2} \cdot \log^k n)$ space. Our work is the first step toward a streaming algorithm for the recognition of $k$-palindromic prefixes.
翻译:回文是指非空且正读反读都相同的字符串。Knuth、Morris和 Pratt在其开创性论文[SIAM J. Comput., 1977]中首次提出了识别以下三类字符串的问题:可表示为偶数长度回文串连接、长度大于一的回文串连接以及恰好$k$个回文串连接的字符串。本文研究$k$回文字符串的识别问题,即能够表示为恰好$k$个回文串连接的字符串。已有研究表明该问题可在线性时间与空间内求解[Rubinchik and Schur, MFCS'2020]。我们致力于开发亚线性空间的解决方案,并取得以下成果:(1) 首先,通过将字符串的所有$k$回文前缀集合表示为少量高度结构化字符串集合(称为仿射前缀集)的并集,我们给出了该集合的结构特征。通过构造几乎匹配的下界,证明该表示的大小具有正确的渐近形式。(2) 其次,我们提出一种只读算法,对于给定长度为$n$的字符串$T$和整数$k$,该算法能为所有$1 \le i \le k$计算$T$的$i$回文前缀的紧凑表示。(3) 最后,我们还给出计算$T$回文长度的只读算法,即在已知$\ell \le k$的条件下,求出使$T$成为$\ell$回文串的最小$\ell$值。这些算法的时间复杂度为$\mathcal O(n \cdot 6^{k^2} \cdot \log^k n)$,空间复杂度为$\mathcal O(6^{k^2} \cdot \log^k n)$。本研究为开发识别$k$回文前缀的流式算法迈出了第一步。