zoukankan      html  css  js  c++  java
  • 【66原创】kmp 为一个图 而深入认识 ,用输出来说话

     

     

    图 来自v_july_v 博客图

     

    2012年4月1日

    21:46

    clip_image002

     

    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的讨论

    clip_image001

    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 处的错找不到。。

  • 相关阅读:
    dhl:asp.net mvc下用jQuery通过AJAX 实现HTTP 请求加载远程数据
    MVC .Routing
    ASP获取当前页URL
    jQuery中的mouseenter和mouseleave事件
    dhl:使用Resharper后还原原来Visual Studio中智能感知
    JSON 数据格式
    转:点击弹出div圆角的遮罩层,可关闭可移动(文章源自:烈火网,原文:http://www.liehuo.net/a/201004/2415766.html)
    15 个一定要会的 Windows7 快捷键
    Asp.Net Mvc中的一些初级问题整理
    Javascript操作form中Field Radio Checkbox Select等的代码
  • 原文地址:https://www.cnblogs.com/titer1/p/2429413.html
Copyright © 2011-2022 走看看