Computer Science > Data Structures and Algorithms
[Submitted on 4 Oct 2024 (v1), last revised 17 Apr 2025 (this version, v4)]
Title:Small Space Encoding and Recognition of $k$-Palindromic Prefixes
View PDFAbstract: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.
Submission history
From: Jonas Ellert [view email][v1] Fri, 4 Oct 2024 10:45:06 UTC (139 KB)
[v2] Wed, 13 Nov 2024 12:55:24 UTC (139 KB)
[v3] Sun, 9 Feb 2025 10:14:48 UTC (106 KB)
[v4] Thu, 17 Apr 2025 14:41:38 UTC (132 KB)
References & Citations
Bibliographic and Citation Tools
Bibliographic Explorer (What is the Explorer?)
Connected Papers (What is Connected Papers?)
Litmaps (What is Litmaps?)
scite Smart Citations (What are Smart Citations?)
Code, Data and Media Associated with this Article
alphaXiv (What is alphaXiv?)
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub (What is DagsHub?)
Gotit.pub (What is GotitPub?)
Hugging Face (What is Huggingface?)
Papers with Code (What is Papers with Code?)
ScienceCast (What is ScienceCast?)
Demos
Recommenders and Search Tools
Influence Flower (What are Influence Flowers?)
CORE Recommender (What is CORE?)
arXivLabs: experimental projects with community collaborators
arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.
Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.
Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.