For this assignment you will be implementing an algorithm capable of pattern-matching substrings in a larger body of text.
Karp-Rabin (or Rabin-Karp) uses rolling hashing to find substrings within a larger string.
Pseudocode for this algorithm is as follows:
def KarpRabin(text, pattern):
hash_pattern = hash(pattern)
for i in range(0, len(text)):
if hash_pattern == hash(text[i:i + len(pattern)]) and text[i:i + len(pattern)] == pattern:
return True
return False
Essentially, we hash the pattern we are looking for, then compare that hash to a hash of a small piece of the main text.
For this task, we use a special "rolling hash" function, similar to the one we've seen on the Princeton slides.
This assignment will be hosted on Github Classroom.
cd ..)git clone <your repository link here>)
karprabin.hpp under Algorithmsgit add . && git commit -m "Done" && git push| Criteria | Points |
|---|---|
| Functional Correctness | 80 |
| Analysis | 10 |
| Quality | 10 |
Submissions are handled by Github Classroom. Submissions after the deadline are not graded.