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