Finding if a substring is present in a string or not.
There are multiple method.
- Brute Force
- Robin Karp Algorithm:
Resource: Video Theory Code
The Rabin–Karp algorithm is inferior for single pattern searching to Knuth–Morris–Pratt algorithm, Boyer–Moore string search algorithm and other faster single pattern string searching algorithms because of its slow worst case behavior. However, it is an algorithm of choice for multiple pattern search.That is, if we want to find any of a large number, say k, fixed length patterns in a text, we can create a simple variant of the Rabin–Karp algorithm that uses a Bloom filteror a set data structure to check whether the hash of a given string belongs to a set of hash values of patterns we are looking for.
- Z-Algorithm:
Resource: Video: 1**, 2 Code: 1 - Knuth–Morris–Pratt(KMP)
Resource: Video: 1 , 2 Code: 1 - Boyer Moore
- Algo Corasik
- Finite State Automata