Table of Contents
Fetching ...

Small Space Encoding and Recognition of $k$-Palindromic Prefixes

Gabriel Bathie, Jonas Ellert, Tatiana Starikovskaya

TL;DR

This work addresses the space efficiency of recognizing $k$-palindromic prefixes (strings that are concatenations of exactly $k$ palindromes) and of computing the palindromic length of a string. It introduces affine prefix sets to compactly encode all $k$-palindromic prefixes, proving a near-optimal space bound $O(6^{k^2}\cdot\log^k n)$ for small $k$, and provides a matching lower bound up to polylog factors. The paper then presents read-only algorithms that, in time $O(n\cdot 6^{k^2}\cdot\log^k n)$ and space $O(6^{k^2}\cdot\log^k n)$, compute the $i$-palindromic prefixes for all $i\le k$ and, separately, the palindromic length in time $O(n\cdot 6^{\ell^2}\cdot\log^{\lceil \ell/2\rceil} n)$ and space $O(6^{\ell^2}\cdot\log^{\lceil \ell/2\rceil} n)$. The approach hinges on decomposing the prefix structure into a small union of affine prefix sets and carefully managing how palindromes extend these sets, including long and short palindromes, via a suite of structural and algorithmic refinements. Overall, the results advance the understanding of small-space processing for complex CFL-like languages and offer practical, space-efficient tools for palindromic-prefix analysis and palindromic-length computation, with nuanced trade-offs between length, alphabet structure, and space usage.

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 \rceil}} n)$ time and $O(6^{\ell^2} \cdot \log^{\lceil{\ell/2\rceil}} 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.

Small Space Encoding and Recognition of $k$-Palindromic Prefixes

TL;DR

This work addresses the space efficiency of recognizing -palindromic prefixes (strings that are concatenations of exactly palindromes) and of computing the palindromic length of a string. It introduces affine prefix sets to compactly encode all -palindromic prefixes, proving a near-optimal space bound for small , and provides a matching lower bound up to polylog factors. The paper then presents read-only algorithms that, in time and space , compute the -palindromic prefixes for all and, separately, the palindromic length in time and space . The approach hinges on decomposing the prefix structure into a small union of affine prefix sets and carefully managing how palindromes extend these sets, including long and short palindromes, via a suite of structural and algorithmic refinements. Overall, the results advance the understanding of small-space processing for complex CFL-like languages and offer practical, space-efficient tools for palindromic-prefix analysis and palindromic-length computation, with nuanced trade-offs between length, alphabet structure, and space usage.

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 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 -palindromic strings, which can be represented as the concatenation of exactly palindromes. We show the following results: 1. First, we show a structural characterization of the set of all -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 -palindromic prefixes in this way requires space. By constructing a lower bound, we show that the space complexity is optimal up to polylogarithmic factors for reasonably small values of . 2. Secondly, we derive a read-only algorithm that, given a string of length and an integer , computes a compact representation of -palindromic prefixes of , for all . The algorithm uses time and space. 3. Finally, we also give a read-only algorithm for computing the palindromic length of , which is the smallest such that is -palindromic. Here, we achieve time and space. For some values of , this is the first algorithm for palindromic length that uses additional working space on top of the input.
Paper Structure (20 sections, 38 theorems, 11 equations, 2 figures)

This paper contains 20 sections, 38 theorems, 11 equations, 2 figures.

Key Result

Theorem 1

Let $0< \epsilon < 1$ be constant. Let $T[1 .\,. n]$ be a string and let $k \in \mathbb N^+$. The set of prefixes of $T$ that belong to $\textnormal{PAL}^k$ is the union of ${\mathcal{O}}(6^{k^2 / (2-\epsilon)} \cdot \log^k n)$ affine prefix sets, each of order at most $k$.

Figures (2)

  • Figure 1: Affine prefix sets.
  • Figure 2: \ref{['lem:aux:structure:factorizesmax']} applied to an irreducible representation $\langle X, (Q_1, 1, 2) \cdot (Q_2, 1, 3) \cdot (Q_3, 1, 2)\rangle$. The drawing shows the longest prefix $S = Q_1^{2} Q_2^{3} Q_3^{2}$ generated by the representation. By the lemma, for any $a_1 \in [0,2]$, $a_2 \in [0,3]$ and $a_3 \in [0,2]$, it holds $S = Q_1^{2 - a_1} Q_2^{3-a_2} Q_3^{2-a_3} \ \cdot\ {\hat{Q}}_3^{a_3}{\hat{Q}}_{2}^{a_{2}}{\hat{Q}}_{1}^{a_1}$, where each ${\hat{Q}}_j$ is the length-$\lvert Q_j\rvert$ suffix of $S$. The drawing highlights the case where $a_1 = a_2 = a_3 = 1$.

Theorems & Definitions (45)

  • Theorem 1
  • Theorem 2
  • Theorem 3
  • Theorem 4
  • Lemma 5: Periodicity Lemma finewilf
  • Lemma 6
  • Lemma 7
  • Lemma 8
  • Corollary 9
  • Theorem 9
  • ...and 35 more