GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Matching Patterns in a string (algorithms)

Hi friends
I am currently learning about "pattern matching" algorithm. I have read many article and book about this concept but when facing a problem I can't choose the best algorithm adapted to the solution. Do you know a trick that let me choose one of this algorithm

- KMP Algorithm
- Rabin-Karp Algorithm
- Boyer-Moore
- Boyer-Moore-Horspool
- Aho-Corasick
- Commentz-Walter
- Wu and Manber
- use Suffix trees/suffix arrays
- Z algorithm (z function)

what algorithme should I use to only count the occurrence of one pattern in one string?
What algorithme should I use to only count the occurrence of many patterns in one string?

What algorithms should I use when searching for the indexes of one pattern in one string?
What algorithms should I use when searching for the indexes of many patterns in one string?


when searching for many patterns in the same string, Is there an algorithme that make a preprocessing on the string so that the time spending to find the occurrence of patterns "one at a time" is minimized?

Thank you very much.

asked Mar 24, 2017 by Mohamed Amine Ouali
...