Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

Manacher's Algorithm

String Algorithm

Manacher's algorithm finds the longest palindromic substring of a string in linear time by processing the string from left to right while maintaining the boundaries of the rightmost palindrome found so far, and using the already-known palindrome lengths of positions mirrored within that rightmost palindrome to avoid recomputing information a previous step has already established, only extending a palindrome check character by character when the mirrored information runs out. This improves on the naive approach of checking every possible center for a palindrome, which takes O(n squared) time in the worst case. Glenn Manacher published the technique in 1975.

Facts
Time Complexity
Linear time 2
Credited To
Manacher, 1975 2
Time Complexity
Time Complexity (category)
Linear Time -- O(n) 1
Connections

In Field

Source Longest palindromic substring, Wikipedia
Sources
1. Manacher's Algorithm (Wikipedia)
  • Wikipedia infobox: time complexity linear
    linear
  • In Group: String Searching Algorithms, Lead
    the longest palindromic substring or longest symmetric factor problem is the problem of finding a maximum-length contiguous substring of a given string that is also a palindrome
View the Source
2. Longest palindromic substring, Wikipedia
  • Manacher's algorithm, Runtime subsection
    The algorithm runs in linear time.
  • Manacher's algorithm, opening sentence
    Manacher (1975) invented an O(n)-time algorithm for listing all the palindromes that appear at the start of a given string of length n.
  • In Field: Algorithms and Complexity Theory, Lead paragraph
View the Source
Wikidata: Manacher's Algorithm
Wikidata Q97401429, class allow-list match (w-wdresolver-0926)View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.