作者cocaincola (☆★)
看板TransCSI
标题[问题] 程式码问题
时间Sun Apr 5 21:47:10 2009
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