Skip to content

The KMP algorithm is a string matching algorithm that uses the LPS (Longest Prefix Suffix) array to avoid unnecessary comparisons. It's more efficient than the naive approach for pattern matching.

Notifications You must be signed in to change notification settings

aditisingh02/kmp-algorithm-visualizer

Repository files navigation

KMP Algorithm Visualizer

A visual tool to understand how the Knuth-Morris-Pratt (KMP) string matching algorithm works in real time.

kmp-algorithm-visualizer.mp4

🔗 KMP Algorithm Visualizer

Features

  • Visualize the pattern preprocessing step (LPS array generation)
  • Step-by-step animation of pattern matching in the text
  • Highlights matches, mismatches, and LPS jumps
  • Clean, interactive UI for better understanding

About KMP

The Knuth-Morris-Pratt (KMP) algorithm is an efficient string matching technique that avoids redundant comparisons by preprocessing the pattern using the LPS (Longest Prefix which is also Suffix) array. This visualizer helps demonstrate how KMP uses the LPS array to achieve linear time matching.


  • React
  • Tailwind CSS
  • TypeScript

Getting Started

To run the project locally:

HTTP

git clone git@github.com:aditisingh02/kmp-algorithm-visualizer.git

SSH

git clone https://github.com/aditisingh02/kmp-algorithm-visualizer.git
cd kmp-algorithm-visualizer
npm install
npm run dev

About

The KMP algorithm is a string matching algorithm that uses the LPS (Longest Prefix Suffix) array to avoid unnecessary comparisons. It's more efficient than the naive approach for pattern matching.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •