2011年7月22日
摘要: 当模式字符串长度数比机器字短和总字符集个数比较少时,Shift-And与Shift-Or算法平均效率是KMP的两倍,下面是Shift-And算法,Shift-Or是同样我思想,只不过用位0表示真状态 1 #include <cstdio> 2 #include <cstring> 3 4 void shiftAnd(char *t, char *p) 5 { 6 int lenP = strlen(p); 7 int b[26] = {0}; 8 for(int i = 0; p[i]; ++i) 9 {10 b[p[i] - 'a'] |= ... 阅读全文
posted @ 2011-07-22 16:48 Kenfly 阅读(1404) 评论(0) 推荐(0) 编辑