17 String Matching - Rabin Karp Algorithm
17 String Matching - Rabin Karp Algorithm
17 String Matching - Rabin Karp Algorithm
Dr. D. P. Acharjya
Professor, SCOPE
SJT Annex – 201 E
Dr. D. P. Acharjya 2/26/2024 11
String Matching Problem
Finding all occurrences of a pattern (String) in a text
leads to string matching problem.
It arises frequently in text editing programs where text
is a document, and the string searched for is a
particular word.
String-matching algorithms are also used to search for
particular patterns in DNA sequences.
For Example:
s = 7 < (n-m) = 14
t8 = (d(t7 – T[8]h) + T[7+5+1]) % 13
= (10(8 – 13) + 6) % 13 = 4
s = 8 < (n-m) = 14
t9 = (d(t8 – T[9]h) + T[8+5+1]) % 13
= (10(4 – 43) + 7) % 13 = 5
s = 9 < (n-m) = 14
t10 =(d(t9 – T[10]h) + T[9+5+1]) % 13
= (10(5 – 13) + 3) % 13 = 10
s = 10 < (n-m) = 14
t11 =(d(t10 – T[11]h) + T[10+5+1]) % 13
= (10(10 – 53) + 9) % 13 = 11
s = 11 < (n-m) = 14
t12 =(d(t11 – T[12]h) + T[11+5+1]) % 13
= (10(11 – 23) + 9) % 13 = 7
s = 13 < (n-m) = 14
t14 =(d(t13 – T[14]h) + T[13+5+1]) % 13
= (10(9 – 73) + 1) % 13 = 11