String Matching Algorithms in C++: KMP Prefix Function Examples
C++ String Matching Algorithms
The following programs implement string matching techniques in C++, mainly the KMP prefix function.
1. Pattern Search in a Cyclic String
This program checks whether a pattern appears in a cyclic version of a string, using the prefix function and indices modulo n.
2. Counting Pattern Occurrences
This program counts how many times a pattern s appears in a text t and compares the count with a given value k, printing "YES" or "NO".
3. Finding Cyclic Shifts
This program searches for one string inside the cyclic extension of another and prints the first position where it occurs.
4. Longest Matching Words
This program converts strings to lowercase, computes the prefix function of each word combined with a pattern, and prints...