kmp 为一个图 而深入认识 ,用输出来说话
来源:互联网 发布:js event 编辑:程序博客网 时间:2024/05/27 00:45
http://www.cnblogs.com/titer1/archive/2012/04/01/2429413.html
图 来自v_july_v 博客图
2012年4月1日
21:46
pattern_index: 0
debug luky target_index: 1
对应 july图中 index =0
pattern_index: 1
debug luky target_index: 2
pattern_index: 2
debug luky target_index: 3
pattern_index: 3
when overlay ,debug target_index: 3
pattern_index: 0
when pattern_index ==0 ,debug target_index: 4
pattern_index: 0
when pattern_index ==0 ,debug target_index: 5
pattern_index: 0
when pattern_index ==0 ,debug target_index: 6
pattern_index: 0
debug luky target_index: 7
对应 july图中 index =6
pattern_index: 1
debug luky target_index: 8
pattern_index: 2
when overlay ,debug target_index: 8
pattern_index: 0
debug luky target_index: 9
对应 july图中 index =8,
图中没有标识
pattern_index: 1
when overlay ,debug target_index: 9
pattern_index: 0
when pattern_index ==0 ,debug target_index: 10
pattern_index: 0
debug luky target_index: 11
对应 july图中 index =10
pattern_index: 1
when overlay ,debug target_index: 11
pattern_index: 0
when pattern_index ==0 ,debug target_index: 12
pattern_index: 0
when pattern_index ==0 ,debug target_index: 13
pattern_index: 0
debug luky target_index: 14
对应 july图中 index =13
pattern_index: 1
debug luky target_index: 15
pattern_index: 2
debug luky target_index: 16
pattern_index: 3
debug luky target_index: 17
pattern_index: 4
when overlay ,debug target_index: 17
pattern_index: 1
这里 发现问题 不一致的bug: 作者给出序
列 程序中的
是
string src="annbcdanacadsannannabnna";
string pattern= "annacanna"
;
实际是:
string src="annbcdanacadsanannacanna"
;就是故意让最后的结尾满足了pattern..
debug luky target_index: 18
pattern_index: 2
debug luky target_index: 19
pattern_index: 3
debug luky target_index: 20
pattern_index: 4
when overlay ,debug target_index: 20
pattern_index: 1
when overlay ,debug target_index: 20
pattern_index: 0
when pattern_index ==0 ,debug target_index: 21
pattern_index: 0
when pattern_index ==0 ,debug target_index: 22
pattern_index: 0
when pattern_index ==0 ,debug target_index: 23
pattern_index: 0
debug luky target_index: 24
-1
作者的勘误:
另一作者saturnman发现,在上述KMP匹配过程图中,index=8和index=11处画错了。还有,anaven也早已发现,index=3处也画错了。非常感谢。但图已无法修改,见谅。
我和 zy的讨论
zy
index = 0 时 annb 算到 k = -1; 所以应该向后移4-(-1+1)次
66
简言之,index=3应该 pass,
为什么这个在我的输出力没有检测 出来??
zy
index = 6 时 ana 算到 k = 0; 所以应该向后移 3-(0+1)次
66
就是说 index=8不应该被 pass
第8 11 处的错找不到。。
- kmp 为一个图 而深入认识 ,用输出来说话
- 为下载而来
- 为你而来
- 为javascript而来
- javascript基础知识(用代码来说话)
- 用一个小例子来认识Java多态
- 简化以下程序,将函数对象 divide_by 转换为一个函数,并将 for 循环替换为用一个标准的 C++ 算法来输出数据
- 为学C语言而来
- QtWebkit2.2为HTML5.0而来
- 未来,为我而来吧!
- 让机器来说话
- “屌丝”身世-由一个低级趣味而来
- 彻底搞懂KMP算法(专为初学者而写)
- 讲一个数按照每一“位”取出来如:64输出为01000000
- 用Java语言来输出一个镂空的金字塔
- 用VS2005为自定义代码段而制作代码段来定义代码段
- 用gdb来调试除数为0而产生的core
- 为一个理想而奋斗一生
- STL模板类总结
- 内存管理内幕
- Linq To XML 和 序列化XML
- Fedora 删除repo
- C++ 面向对象的笔记总结
- kmp 为一个图 而深入认识 ,用输出来说话
- c++ 面试总结(一)
- kmp 领悟代码
- Mysql Event Scheduler
- 树形结构的处理——组合模式(一)
- 奇偶调序(新的方法实现)
- 第 6 章:内存池
- 用Heartbeat配置Linux高可用性集群
- 超级程序员神话