Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Rabin_Karp.py #492

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Udit19-pixel
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant