KMP String Matching Visualizer

by Hudson Griffith

The Knuth-Morris-Pratt (KMP) algorithm is an efficient string-matching algorithm that finds occurrences of a pattern string within a main text string. Unlike naive approaches that may involve redundant comparisons, KMP utilizes a preprocessed table called the LPS (Longest Proper Prefix which is also Suffix) to skip unnecessary comparisons.

Time Complexity: O(n + m)
Space Complexity: O(m)
Main Text
Search Target

Enter text and pattern, then press Start to begin visualization.

Back to Main Page