RABIN-KARP-MATCHER(T,P,d,q) 1 n T.length 问题⑨: 2 m P.length 3 h=dm-1 mod q 影响复樂度的 4p=0 关健是什么? 5 to=0 6 for i 1 to m /∥oreprocessing 7 p=(dp+p[i])mod g 8 to =(dto +T[i])mod q 9 for s 0to n-m ∥matching 10 if p==ts 11 if P[1..m]==T[s +1..s +m] 12 print“Pattern occurs with shift'”s 13 ifs n-m 14 ts+1=(d(ts-T[s +1]h)+T[s +m +1))mod q