Using the Rabin Karp algorithm, find the pattern string in the given text. Pattern: “fed”, Text: “acfeddadfdec”. Write all the steps involved.
"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.\\\\"
Comments
Leave a comment