This repository contain source code for the course project
Propose and implement an algorithm to solve pattern matching problem. Analyse algorithm complexity.
- A long paragraph
- Several patterns to search for
- For each pattern, if exist in paragraph, print out all its occurrences
- Construct a suffix array from given paragraph
- Use binary search algorithm to find the pattern
- Initialization: O(N^2 * logN)
- String compare: O(N)
- Quicksort: O(NlogN)
- Searching: O(M * logN * P)
- String compare: O(M)
- Binary search: O(logN)
With
- N is the length of the paragraph
- M is the length of the pattern
- P is the number of patterns
https://cp-algorithms.com/string/suffix-array.html#finding-a-substring-in-a-string