Examveda

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” s

B.

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” s

C.

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” s

D.

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” s

Answer: Option B


This Question Belongs to Data Structure >> String Matching

Join The Discussion

Related Questions on String Matching