Starting from:
$30

$24

Homework 06: Rabin-Karp Algorithm Solution

Instruction




Submit your answer to this question via PC^2 under your account by the posted due time. No late submissions will be accepted. Note that homework is opened-book, but no outside assistance is permitted.




Problem




Given a text txt[0.. nt -1], a pattern pat[0..np-1], the number of slots in hash table m, and the number of characters in input alphabet a, write a function search(pat, txt, m, a) that prints all occurrences of pat in txt. You may assume that nt np.










Sample input




Searching for Patterns,rchi,101,256




Smartphone photo,ph,101,256







Sample output




Pattern found at index 3




Done




Pattern found at index 5




Pattern found at index 11




Done

More products