摘要: 依照KMP实现的算法,附带测试用例。#include <algorithm>#include<iostream>#include<iterator>#include <string>#include <vector>#include <cassert>#include <cstring>using namespace std;/**计算next***/void kmp_next(char *pattern,int *next){ int i = 0 ; int j = next[0] = -1; while(p 阅读全文
posted @ 2011-05-04 14:13 westfly 阅读(462) 评论(0) 推荐(0) 编辑
摘要: KMP算法引用最多的是Matrix67的大作KMP算法详解 该文对KMP算法有个详细的介绍,从宏观上了解下吧。还有其提到 "由于KMP算法只预处理B串,因此这种算法很适合这样的问题:给定一个B串和一群不同的A串,问B是哪些A串的子串。"。其姊妹文章KMP算法与一个经典概率问题未看——有时间再关注将KMP作为自动机KMP算法深度解析KMP算法并非凭空而来,而是基于有线自动机的。该文的图形引用得比较多。从自动机(NFA to DFA)角度去理解KMP和Shift-And/Shift-or算法文中提到了本《Flexible Pattern Matching inStrings》的 阅读全文
posted @ 2011-05-04 14:06 westfly 阅读(384) 评论(0) 推荐(0) 编辑