🤖 AI Summary
This paper addresses the efficient identification and compact representation of all *k-palindromic prefixes* of a string—i.e., prefixes admitting a decomposition into exactly *k* concatenated palindromes. We introduce the novel *affine prefix set* data structure to characterize the set of *k*-palindromic prefixes and establish tight asymptotic bounds on its space complexity. Leveraging combinatorial string analysis, recursive divide-and-conquer, and read-only random-access techniques, we design the first sublinear-extra-space algorithm for computing palindrome lengths. Our main contributions are: (1) an optimal encoding scheme using *O*(6<sup>*k*²</sup> · log<sup>*k*</sup> *n*) space; (2) an enumeration algorithm listing all *k*-palindromic prefixes in *O*(*n* · 6<sup>*k*²</sup> · log<sup>*k*</sup> *n*) time; and (3) the first *o*(*n*)-extra-space solution for palindrome-length computation—breaking the long-standing linear-space barrier and significantly advancing the theoretical and algorithmic understanding of *k*-palindromic structures.
📝 Abstract
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 at least two, 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. We 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. Representing the lengths of the $k$-palindromic prefixes in this way requires $O(6^{k^2} cdot log^k n)$ space. By constructing a lower bound, we show that the space complexity is optimal up to polylogarithmic factors for reasonably small values of $k$. 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 $i$-palindromic prefixes of $T$, for all $1 le i le k$. The algorithm uses $O(n cdot 6^{k^2} cdot log^k n)$ time and $O(6^{k^2} cdot log^k n)$ space. 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. Here, we achieve $O(n cdot 6^{ell^2} cdot log^{lceil{ell/2
ceil}} n)$ time and $O(6^{ell^2} cdot log^{lceil{ell/2
ceil}} n)$ space. For some values of $ell$, this is the first algorithm for palindromic length that uses $o(n)$ additional working space on top of the input.