-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Description
What would you like to Propose?
Issue Title:
Add KMP (Knuth–Morris–Pratt) String Matching Algorithm Implementation
Description:
I would like to request the addition of the KMP string matching algorithm to this repository.
This algorithm efficiently finds occurrences of a pattern within a text using preprocessing of the pattern to avoid redundant comparisons.
Why this is useful:
KMP runs in O(n + m) time, making it much faster than the naïve string matching algorithm.
It’s a classic example of efficient pattern searching, useful in various applications like text editors, DNA sequence matching, and plagiarism detection.
Adds educational and algorithmic value to the repository.
Proposed Implementation:
Implement the kmp_search(text, pattern) function in Python/Java/C++ (depending on project language) that:
Builds the LPS (Longest Prefix Suffix) array for the pattern.
Uses it to efficiently search for the pattern in the text.
Issue details
Why this is useful:
KMP runs in O(n + m) time, making it much faster than the naïve string matching algorithm.
It’s a classic example of efficient pattern searching, useful in various applications like text editors, DNA sequence matching, and plagiarism detection.
Adds educational and algorithmic value to the repository.
Proposed Implementation:
Implement the kmp_search(text, pattern) function in Python/Java/C++ (depending on project language) that:
Builds the LPS (Longest Prefix Suffix) array for the pattern.
Uses it to efficiently search for the pattern in the text.
Additional Information
No response