Created a Python file to implement the Rabin-Karp algorithm for searching a pattern in a given text.
Explanation to the algorithm : -
The Rabin Karp algorithm is a string search algorithm that uses hashing to find the given pattern in the text.
This algorithm computes the hash value of the pattern for that iteration and for each substring, compares that hash value with the subsequent pattern.
If the hash value matches, the algorithm performs a string comparison, otherwise that window is not entertained further.
The average time complexity of this algorithm is O(m+n) where n is the text length and m is the pattern length, whereas the worst case time complexity is O(mn).
Created a Python file to implement the Rabin-Karp algorithm for searching a pattern in a given text.
Explanation to the algorithm : -