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=101x=10hash[fed]=(102102+10110+100)mod101=99i=1:hash[acf]=(97102+9910+102=10792)mod101=8699i=2:hash[cfe]=(99102+10210+101)mod101=1299i=3:hash[fed]=(102102+10110+100)mod101=99End  of  procedure.Position  3.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