Small Space Encoding and Recognition of k-Palindromic Prefixes
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(6k2 · 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 i k. The algorithm uses O(n · 6k2 · k n) time and O(6k2 · k n) space. 3. Finally, we also give a read-only algorithm for computing the palindromic length of T, which is the smallest such that T is -palindromic. Here, we achieve O(n · 6^2 · /2 n) time and O(6^2 · /2 n) space. For some values of , this is the first algorithm for palindromic length that uses o(n) additional working space on top of the input.
Turn this paper into a full lesson
ArcXiv compiles a staged curriculum from this paper: 8-12 lessons across beginner → advanced, synthesised section guides, visuals, flashcards, a quiz, exercises, and on-demand deep dives per section. Grounded in the abstract, never invented.