Answer to Question #323534 in Algorithms for ruhi

Question #323534

Using the Rabin Karp algorithm, find the pattern string in the given text. Pattern: “fed”, Text: “acfeddadfdec”. Write all the steps involved.





1
Expert's answer
2022-04-05T13:18:36-0400

"Choose\\,\\,the\\,\\,hash\\,\\,function:\\\\q=101\\\\x=10\\\\hash\\left[ fed \\right] =\\left( 102\\cdot 10^2+101\\cdot 10+100 \\right) mod101=99\\\\i=1: hash\\left[ acf \\right] =\\left( 97\\cdot 10^2+99\\cdot 10+102=10792 \\right) mod101=86\\ne 99\\\\i=2: hash\\left[ cfe \\right] =\\left( 99\\cdot 10^2+102\\cdot 10+101 \\right) mod101=12\\ne 99\\\\i=3: hash\\left[ fed \\right] =\\left( 102\\cdot 10^2+101\\cdot 10+100 \\right) mod101=99\\\\End\\,\\,of\\,\\,procedure. Position\\,\\,3.\\\\"


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS