Papers
Topics
Authors
Recent
Search
2000 character limit reached

Manacher Arrays: Palindrome Detection & Reconstruction

Updated 6 July 2026
  • 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 SS of length nn, the classical formulation stores radii for the $2n-1$ half-integer centers, thereby reconstructing the set of all maximal palindromic substrings of SS in overall O(n)O(n) time via Manacher’s algorithm (Itzhaki, 18 Jul 2025). Closely related formulations separate odd and even centers into two arrays d1[0..n1]d_1[0..n-1] and d2[0..n1]d_2[0..n-1], where d1[i]d_1[i] is the radius of the longest odd-length palindrome centered at ii and d2[i]d_2[i] is the radius of the longest even-length palindrome centered between nn0 and nn1 (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 nn2 be a string over an alphabet nn3. One formulation defines a Manacher array nn4 by assigning to each odd index nn5 the value

nn6

and to each even index nn7 the value

nn8

Thus nn9 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 SS0 (Mieno, 20 Aug 2025).

A third common formulation embeds the string into a virtual augmented string SS1 of length SS2, where original symbols occupy odd positions and a sentinel occupies even positions. The radius array SS3 then satisfies

SS4

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 SS5 time (Itzhaki, 18 Jul 2025). In the two-array formulation, a standard in-place scan computes SS6 in SS7, and an almost identical loop computes SS8 in SS9 as well; the overall time remains O(n)O(n)0 (Mieno, 20 Aug 2025). On an unordered alphabet, the time is O(n)O(n)1 comparisons, assuming each character fits in a machine word, while the two arrays O(n)O(n)2 take O(n)O(n)3 words, that is O(n)O(n)4 bits (Mieno, 20 Aug 2025).

The augmented-string formulation exploits the mirror relation around the current center O(n)O(n)5. If O(n)O(n)6 is the rightmost boundary reached so far, then for a new center O(n)O(n)7,

O(n)O(n)8

and

O(n)O(n)9

The algorithm then expands around d1[0..n1]d_1[0..n-1]0 while the matched characters agree, and if d1[0..n1]d_1[0..n-1]1 exceeds the previous right boundary, it updates d1[0..n1]d_1[0..n-1]2 and d1[0..n1]d_1[0..n-1]3 (Wan, 2020). The resulting runtime is d1[0..n1]d_1[0..n-1]4, where d1[0..n1]d_1[0..n-1]5 is the original string length (Wan, 2020).

A notable implementation refinement avoids explicitly building the augmented string. Instead, the virtual character access

d1[0..n1]d_1[0..n-1]6

is computed on the fly. This index-mapping implementation keeps only the radius array d1[0..n1]d_1[0..n-1]7, thereby eliminating storage for the augmented string d1[0..n1]d_1[0..n-1]8; the extra memory becomes solely d1[0..n1]d_1[0..n-1]9 for d2[0..n1]d_2[0..n-1]0, rather than storing both d2[0..n1]d_2[0..n-1]1 and d2[0..n1]d_2[0..n-1]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 d2[0..n1]d_2[0..n-1]3 denote the number of distinct Manacher arrays of length d2[0..n1]d_2[0..n-1]4 arising from strings of length d2[0..n1]d_2[0..n-1]5, and let d2[0..n1]d_2[0..n-1]6 denote the number of non-isomorphic rooted tandem-duplication trees with d2[0..n1]d_2[0..n-1]7 leaves. A principal result establishes

d2[0..n1]d_2[0..n-1]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” d2[0..n1]d_2[0..n-1]9 satisfying

d1[i]d_1[i]0

The paper states a chain of bijections

d1[i]d_1[i]1

together with an encoding of each duplication event d1[i]d_1[i]2 as a strictly decreasing block d1[i]d_1[i]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 d1[i]d_1[i]4 of a string of length d1[i]d_1[i]5, one has d1[i]d_1[i]6 for all d1[i]d_1[i]7, at most one nonzero “center” appears per index, and the total sum of all radii satisfies

d1[i]d_1[i]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 d1[i]d_1[i]9 of maximal palindromic intervals, called the palindromic fingerprint. From ii0, one constructs an equality graph ii1 on vertices ii2, where ii3 if positions ii4 and ii5 must carry the same symbol in any reconstruction, and a restriction graph ii6 whose vertices are the connected components of ii7, 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 ii8, proper vertex-colorings of ii9 are in bijection with strings d2[i]d_2[i]0 of length d2[i]d_2[i]1 whose Manacher array is d2[i]d_2[i]2. Each color class corresponds to a symbol used in the reconstruction. Consequently, the minimal alphabet size required to realize d2[i]d_2[i]3 is exactly the chromatic number d2[i]d_2[i]4 (Itzhaki, 18 Jul 2025).

This characterization yields an exact decision and construction procedure for prescribed alphabet size. For a target d2[i]d_2[i]5, one builds d2[i]d_2[i]6 from the fingerprint d2[i]d_2[i]7 in polynomial time, checks whether

d2[i]d_2[i]8

and if the condition holds, starts from a minimal coloring of d2[i]d_2[i]9 and greedily splits color classes until nn00 colors are obtained, then translates the nn01-coloring back to a string. The procedure resolves an open problem in the affirmative with an nn02-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 nn03 distinct symbols, and adaptability to produce reconstructions over arbitrary alphabets when possible (Itzhaki, 18 Jul 2025). More precisely, the bound is stated as

nn04

and it is tight for infinitely many nn05 (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 nn06, which has length at least nn07; hence if nn08 symbols have appeared by position nn09, then nn10, giving nn11 (Itzhaki, 18 Jul 2025). The paper also defines palindromic dependency: index nn12 is palindromically dependent on nn13 if there is a maximal palindrome nn14 with center nn15, forcing nn16 to equal a symmetric position within nn17 (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 nn18 machine words, or nn19 bits, because the arrays nn20 and nn21 each have length nn22 (Mieno, 20 Aug 2025). Subsequent work has sought linear-bit encodings with efficient query support.

One line of results gives an nn23-bit representation for all maximal palindromes with nn24-time retrieval of the maximal even-palindrome length nn25 (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 nn26. Since this encoding alone does not support nn27 retrieval, the structure partitions centers into “long” and “short” cases using a parameter nn28 and a bit-vector nn29, where nn30 iff nn31 (Mieno, 20 Aug 2025).

For long palindromes, centers are grouped into blocks of length nn32. If a block contains at most two long palindromes, the pairs are stored explicitly in nn33 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 nn34 bits total per block (Mieno, 20 Aug 2025). For short palindromes, each lies within a window of length nn35; distinct window strings are locally encoded by the unary-difference method, and a global lookup table answers queries in nn36 time (Mieno, 20 Aug 2025). Combined, storing nn37, the long-palindrome structure, and the short-palindrome structure yields total space nn38 bits and query time nn39 (Mieno, 20 Aug 2025).

A different compression approach encodes the Manacher array nn40 through differential offsets between centers of nontrivial maximal palindromes and gamma-encodes these differences. If nn41, where nn42 is the center of the nn43th nontrivial maximal palindrome in a left-to-right sweep, then nn44, and the total gamma-encoded size is nn45 bits (Itzhaki, 2024). From nn46, the entire radius array can be reconstructed in nn47 time by replaying the mirroring steps of Manacher’s algorithm (Itzhaki, 2024).

The same work states a lower bound: even if nn48, the Manacher array of nn49 already suffices to recover nn50 up to a 6-element permutation, so one cannot beat nn51 bits in the worst case (Itzhaki, 2024). It further gives a zero-order entropy bound

nn52

and therefore

nn53

bits when the alphabet size is nn54 (Itzhaki, 2024). Together these imply

nn55

When nn56, this becomes nn57 bits, while for nn58 the upper bound is nn59 bits (Itzhaki, 2024).

Beyond sequential decoding, the same paper gives a random-access index using

nn60

of space, that is nn61 bits, and supporting nn62 in

nn63

time after nn64-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).

Because Manacher arrays encode all maximal palindromic structure, they serve as a substrate for other indexing problems. Using the nn65-bit maximal-palindrome representation, one can preprocess a string into an nn66-bit data structure that computes the longest palindrome appearing in any given factor nn67 in nn68 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 nn69 (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 nn70 needed for any preimage of a given Manacher array and the Lempel–Ziv complexity nn71 of the radius sequence. Specifically, if the lexicographically minimal string realizing nn72 has alphabet size nn73, then palindromic Zimin-word structure forces

nn74

(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 nn75 bits while still supporting nn76-time access to nn77; 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.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (4)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Manacher Arrays.