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 Time Complexity
Time Complexity (category) 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 Source2. 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 SourceWikidata: Manacher's Algorithm
Wikidata Q97401429, class allow-list match (w-wdresolver-0926)View the Source Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.