Overview
Morris-Pratt handles exact string matching by using prefix borders to avoid rechecking matched characters.
Morris-Pratt uses using prefix borders to avoid rechecking matched characters for exact string matching.
Compact metadata for implementation and discovery.
Morris-Pratt handles exact string matching by using prefix borders to avoid rechecking matched characters.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n + m)
Worst
O(n + m)
Space
O(n + m)
Show using prefix borders to avoid rechecking matched characters on a small exact string matching example.
Morris-Pratt operates in O(n + m) time and O(n + m) space within the String Matching family. Often compared with Bit-Parallel Levenshtein and Shift-And Algorithm.
What each reference supports for this entry.
String algorithms reference for Morris-Pratt's pattern matching, suffix indexing, alignment, or sequence-processing mechanism.
Open sourceTextbook support for Morris-Pratt's algorithm family, complexity framing, and standard implementation concepts.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Pattern Matching · Core
Both address exact string matching, but they make different modeling or performance tradeoffs.
Compare with thisBoth address exact string matching, but they make different modeling or performance tradeoffs.
Both address exact string matching, but they make different modeling or performance tradeoffs.
Both address exact string matching, but they make different modeling or performance tradeoffs.