If n is the length of text(T) and m is the length of the pattern(P) identify the correct matching algorithm.
A.
for s=0 to n
do if p=t0
then if P[1..m]=T[s+1..s+m]
then print “Pattern occurs with shift” sB.
for s=0 to n-m
do if p=ts
then if P[1..m]=T[s+1..s+m]
then print “Pattern occurs with shift” sC.
for s=0 to m
do if p=ts
then if P[1..m]=T[s+1..s+m]
then print “Pattern occurs with shift” sD.
for s=0 to n-m
do if p!=ts
then if P[1..m]=T[s+1..s+m]
then print “Pattern occurs with shift” sAnswer: Option B

Join The Discussion