看板 TransCSI 關於我們 聯絡資訊
Show that the following brute-force string matching algoritm takes average linear time to report all occurrences of a pattern string p in a text string t. 1:Let m = length of p;n=length of t; 2:for i = 1 to n-m+1 do 3: j=1; 4: while j<=m and p[j]=t[i+j-1] do 5: j=j+1; 6: if j>m then 7: Print i ; -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.127.38.23