Manacher Arrays: Palindrome Detection & Reconstruction
- Manacher arrays are integer arrays that capture the maximal palindromic radius at every half-integer center of a string, unifying odd- and even-length palindrome detection in O(n) time.
- They underpin efficient reconstruction algorithms and compressed representations, offering practical methods for string analysis, pattern matching, and alphabet minimization.
- Recent research examines their combinatorial structure and graph-theoretic characterizations, linking them to duplication trees and setting bounds for succinct encoding.
Searching arXiv for papers on Manacher arrays, maximal palindromes, and related compression/reconstruction results. Manacher arrays are integer arrays that encode the maximal palindromic radius at every admissible center of a string. For a string of length , the classical formulation stores radii for the $2n-1$ half-integer centers, thereby reconstructing the set of all maximal palindromic substrings of in overall time via Manacher’s algorithm (Itzhaki, 18 Jul 2025). Closely related formulations separate odd and even centers into two arrays and , where is the radius of the longest odd-length palindrome centered at and is the radius of the longest even-length palindrome centered between 0 and 1 (Mieno, 20 Aug 2025). Recent work has shifted attention from computation alone to combinatorics, reconstruction, alphabet minimization, and succinct or compressed representations of these arrays (Itzhaki, 18 Jul 2025, Mieno, 20 Aug 2025, Itzhaki, 2024).
1. Formal definitions and equivalent encodings
Let 2 be a string over an alphabet 3. One formulation defines a Manacher array 4 by assigning to each odd index 5 the value
6
and to each even index 7 the value
8
Thus 9 records the maximal palindromic radius around each of the $2n-1$0 half-integer centers, and equivalently determines the set of all maximal palindromic substrings of $2n-1$1 (Itzhaki, 18 Jul 2025).
An alternative but standard representation uses two arrays. For $2n-1$2, $2n-1$3 stores odd-center radii and $2n-1$4 stores even-center radii: $2n-1$5
$2n-1$6
The maximal odd palindrome at $2n-1$7 has length $2n-1$8, while the maximal even palindrome with center at $2n-1$9 has length 0 (Mieno, 20 Aug 2025).
A third common formulation embeds the string into a virtual augmented string 1 of length 2, where original symbols occupy odd positions and a sentinel occupies even positions. The radius array 3 then satisfies
4
This representation unifies odd- and even-length palindromes into a single array over virtual centers (Wan, 2020).
These definitions are equivalent at the level of maximal palindromic structure. In many applications one folds odd and even palindromes into a single array of maximal palindrome lengths by doubling characters, although some treatments retain separate arrays for clarity (Mieno, 20 Aug 2025).
2. Linear-time computation and implementation variants
Manacher’s classical algorithm computes palindrome radii for every center in overall 5 time (Itzhaki, 18 Jul 2025). In the two-array formulation, a standard in-place scan computes 6 in 7, and an almost identical loop computes 8 in 9 as well; the overall time remains 0 (Mieno, 20 Aug 2025). On an unordered alphabet, the time is 1 comparisons, assuming each character fits in a machine word, while the two arrays 2 take 3 words, that is 4 bits (Mieno, 20 Aug 2025).
The augmented-string formulation exploits the mirror relation around the current center 5. If 6 is the rightmost boundary reached so far, then for a new center 7,
8
and
9
The algorithm then expands around 0 while the matched characters agree, and if 1 exceeds the previous right boundary, it updates 2 and 3 (Wan, 2020). The resulting runtime is 4, where 5 is the original string length (Wan, 2020).
A notable implementation refinement avoids explicitly building the augmented string. Instead, the virtual character access
6
is computed on the fly. This index-mapping implementation keeps only the radius array 7, thereby eliminating storage for the augmented string 8; the extra memory becomes solely 9 for 0, rather than storing both 1 and 2 (Wan, 2020). The reported significance is practical rather than asymptotic: the preprocessing is “neither economic nor necessary,” and index mapping avoids the need to choose a dummy character absent from the input alphabet (Wan, 2020).
3. Combinatorial structure and enumeration
Recent work has treated Manacher arrays as combinatorial objects in their own right. Let 3 denote the number of distinct Manacher arrays of length 4 arising from strings of length 5, and let 6 denote the number of non-isomorphic rooted tandem-duplication trees with 7 leaves. A principal result establishes
8
showing that there are strictly more rooted tandem-duplication trees than Manacher arrays (Itzhaki, 18 Jul 2025).
The proof proceeds through a family of “counter arrays” 9 satisfying
0
The paper states a chain of bijections
1
together with an encoding of each duplication event 2 as a strictly decreasing block 3 (Itzhaki, 18 Jul 2025).
This combinatorial viewpoint reframes the Manacher array as more than a byproduct of palindrome detection. It becomes an object subject to enumeration, structural constraints, and nontrivial comparison with independently studied tree families. A plausible implication is that the radius sequence captures a highly structured subset of all locally consistent integer arrays, which helps explain why it supports strong reconstruction theorems and succinct encodings.
A related combinatorial observation appears in compression work: for a Manacher array 4 of a string of length 5, one has 6 for all 7, at most one nonzero “center” appears per index, and the total sum of all radii satisfies
8
This bound underlies a linear-bit differential encoding of the nontrivial centers (Itzhaki, 2024).
4. Reconstruction, graph-theoretic characterization, and alphabet minimization
A major development is the reconstruction of strings from Manacher arrays through a graph-theoretic framework. Rather than work directly with radii, one may pass to the set 9 of maximal palindromic intervals, called the palindromic fingerprint. From 0, one constructs an equality graph 1 on vertices 2, where 3 if positions 4 and 5 must carry the same symbol in any reconstruction, and a restriction graph 6 whose vertices are the connected components of 7, with an edge between two components whenever positions in one must differ from positions in the other (Itzhaki, 18 Jul 2025).
The central theorem states that for a valid Manacher array 8, proper vertex-colorings of 9 are in bijection with strings 0 of length 1 whose Manacher array is 2. Each color class corresponds to a symbol used in the reconstruction. Consequently, the minimal alphabet size required to realize 3 is exactly the chromatic number 4 (Itzhaki, 18 Jul 2025).
This characterization yields an exact decision and construction procedure for prescribed alphabet size. For a target 5, one builds 6 from the fingerprint 7 in polynomial time, checks whether
8
and if the condition holds, starts from a minimal coloring of 9 and greedily splits color classes until 00 colors are obtained, then translates the 01-coloring back to a string. The procedure resolves an open problem in the affirmative with an 02-time algorithm (Itzhaki, 18 Jul 2025).
The same work analyzes a left-to-right reconstruction algorithm due to I et al. (SPIRE 2010). The algorithm builds a lexicographically minimal string achieving the given Manacher array and is shown to have three properties: global minimality of the alphabet, use of at most 03 distinct symbols, and adaptability to produce reconstructions over arbitrary alphabets when possible (Itzhaki, 18 Jul 2025). More precisely, the bound is stated as
04
and it is tight for infinitely many 05 (Itzhaki, 18 Jul 2025).
The extremal analysis is tied to Palindromic Zimin words. The derivation shows that each newly introduced symbol must be preceded by a palindrome structure matching a Palindromic Zimin word of degree 06, which has length at least 07; hence if 08 symbols have appeared by position 09, then 10, giving 11 (Itzhaki, 18 Jul 2025). The paper also defines palindromic dependency: index 12 is palindromically dependent on 13 if there is a maximal palindrome 14 with center 15, forcing 16 to equal a symmetric position within 17 (Itzhaki, 18 Jul 2025).
An important contrast is that general “dependency” reconstruction is NP-hard, whereas the palindromic special case is easy because of the very structured restriction graph (Itzhaki, 18 Jul 2025). This suggests that the tractability of Manacher-array reconstruction is due not merely to local equalities but to the highly constrained geometry imposed by maximal palindromes.
5. Succinct and compressed representations
Classically, storing all maximal palindrome radii requires 18 machine words, or 19 bits, because the arrays 20 and 21 each have length 22 (Mieno, 20 Aug 2025). Subsequent work has sought linear-bit encodings with efficient query support.
One line of results gives an 23-bit representation for all maximal palindromes with 24-time retrieval of the maximal even-palindrome length 25 (Mieno, 20 Aug 2025). The representation first encodes the sequence of centers of longest even-palindromic suffixes in unary differences, obtaining a bit string of total length 26. Since this encoding alone does not support 27 retrieval, the structure partitions centers into “long” and “short” cases using a parameter 28 and a bit-vector 29, where 30 iff 31 (Mieno, 20 Aug 2025).
For long palindromes, centers are grouped into blocks of length 32. If a block contains at most two long palindromes, the pairs are stored explicitly in 33 bits each. Otherwise, by a periodicity lemma, the centers form an arithmetic progression and the lengths decompose into at most two arithmetic progressions plus one exception; the representation stores the progression parameters and linear formulas in 34 bits total per block (Mieno, 20 Aug 2025). For short palindromes, each lies within a window of length 35; distinct window strings are locally encoded by the unary-difference method, and a global lookup table answers queries in 36 time (Mieno, 20 Aug 2025). Combined, storing 37, the long-palindrome structure, and the short-palindrome structure yields total space 38 bits and query time 39 (Mieno, 20 Aug 2025).
A different compression approach encodes the Manacher array 40 through differential offsets between centers of nontrivial maximal palindromes and gamma-encodes these differences. If 41, where 42 is the center of the 43th nontrivial maximal palindrome in a left-to-right sweep, then 44, and the total gamma-encoded size is 45 bits (Itzhaki, 2024). From 46, the entire radius array can be reconstructed in 47 time by replaying the mirroring steps of Manacher’s algorithm (Itzhaki, 2024).
The same work states a lower bound: even if 48, the Manacher array of 49 already suffices to recover 50 up to a 6-element permutation, so one cannot beat 51 bits in the worst case (Itzhaki, 2024). It further gives a zero-order entropy bound
52
and therefore
53
bits when the alphabet size is 54 (Itzhaki, 2024). Together these imply
55
When 56, this becomes 57 bits, while for 58 the upper bound is 59 bits (Itzhaki, 2024).
Beyond sequential decoding, the same paper gives a random-access index using
60
of space, that is 61 bits, and supporting 62 in
63
time after 64-time preprocessing (Itzhaki, 2024). The design partitions centers into non-periodic and periodic cases; non-periodic radii are stored in a CF-Array, while periodic regions are represented by period descriptors and auxiliary rank/select bitvectors (Itzhaki, 2024).
6. Applications, related structures, and open directions
Because Manacher arrays encode all maximal palindromic structure, they serve as a substrate for other indexing problems. Using the 65-bit maximal-palindrome representation, one can preprocess a string into an 66-bit data structure that computes the longest palindrome appearing in any given factor 67 in 68 time (Mieno, 20 Aug 2025). The method decomposes the answer into longest palindromic prefix, longest palindromic suffix, and best interior maximal palindrome; prefix and suffix lengths are found by binary search over centers using RMQ on an auxiliary array, and the interior answer uses an RMQ over 69 (Mieno, 20 Aug 2025).
Compressed-representation work also connects Manacher arrays with Lempel–Ziv complexity and alphabet size. One result states a one-to-one link between the minimal alphabet size 70 needed for any preimage of a given Manacher array and the Lempel–Ziv complexity 71 of the radius sequence. Specifically, if the lexicographically minimal string realizing 72 has alphabet size 73, then palindromic Zimin-word structure forces
74
(Itzhaki, 2024). This indicates that small alphabet size, Zimin-type extremal structure, and compressibility of the radius sequence are tightly coupled phenomena.
Several open directions are explicitly identified. One is to obtain a data structure using 75 bits while still supporting 76-time access to 77; the stated obstacle is a trade-off between long-run periodic cases and the CF-array’s local constraints (Itzhaki, 2024). Another is extension to two-dimensional palindromic pictures or higher-order palindromic factorizations (Itzhaki, 2024).
A recurring misconception is that the Manacher array is only an auxiliary artifact for longest-palindromic-substring computation. The cited work shows a broader picture: it supports exact reconstruction up to graph coloring (Itzhaki, 18 Jul 2025), admits nontrivial counting bounds via duplication trees (Itzhaki, 18 Jul 2025), and can be stored in linear bits with constant or near-constant access guarantees (Mieno, 20 Aug 2025, Itzhaki, 2024). This suggests that Manacher arrays occupy a central role in the algorithmics and combinatorics of palindromic structure, rather than merely serving as an implementation detail of a classical linear-time scan.