Failure link 2026-10-20
A transition to a shorter suffix match after an attempted extension fails. In a Knuth-Morris-Pratt automaton, the prefix function determines the next shorter matching prefix.
Kevin Wayne Created 2026-10-13 Updated 2026-11-05
Kevin Wayne is a coauthor of Algorithms, 4th edition by Robert Sedgewick and others and Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and others. Their accompanying implementations connect abstract data types, algorithm invariants and resource analysis to executable programs. For example, the published Knuth-Morris-Pratt automaton implementation explicitly accounts for alphabet-dependent preprocessing and space.[ref]
Knuth-Morris-Pratt algorithm Created 2026-10-20 Updated 2026-11-05
The Knuth-Morris-Pratt algorithm searches for a pattern using its proper prefix-suffix overlaps. After matching characters, a mismatch replaces by the length of the longest proper border of a string for that matched prefix, repeating until the next character can extend it or . The text index never moves backward. Precomputing prefix failure links takes time; during scanning each increase in can pay for a later decrease, giving total character work and auxiliary storage. A dense Knuth-Morris-Pratt automaton is a related implementation with alphabet-dependent preprocessing and storage.[ref]
Knuth-Morris-Pratt automaton Created 2026-10-20 Updated 2026-11-05
A Knuth-Morris-Pratt automaton records how much of a fixed pattern matches the suffix of the text seen so far. State means the longest such prefix has length ; reading a symbol moves to the longest compatible prefix state. Reaching state reports a full length- match. For pattern aba, state two records suffix ab; reading a completes the match, while reading b falls back to state zero. A dense table for an alphabet of size uses preprocessing and storage, then constant work per text symbol.[ref]