知识卡片
朴素匹配逐位移比较整个模式
朴素字符串匹配枚举s=0到n−m,在每个位移比较模式P与对应文本片段;相等就报告该位移。
它不预处理模式,也不跨位移保存已比较的信息。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第32章 字符串匹配 · 查看原书依据
The NAIVE-STRING-MATCHER procedure finds all valid shifts using a loop that checks the condition P[1:m] = T[s+1:s+m] for each of the n−m+1 possible values of s. NAIVE-STRING-MATCHER(T, P, n, m) 1 for s = 0 to n – m 2 if P[1:m] == T[s + 1:s + m] 3 print “Pattern occurs with shift” s Figure 32.3 portrays the naive string-matching procedure as sliding a
参考来源
- 位置:《算法导论(第4版)》第32章《字符串匹配》(OEBPS/chapter032.xhtml,文本字符[5000,10000))。
- 结论依据:原文定义字符串匹配、前后缀或相应算法的比较规则;相关图式已核对。
- 原始内容:The N AIVE -S TRING -M ATCHER procedure finds all valid shifts using a loop that checks the condition P [1: m ] = T [ s +1: s + m ] for each of the n − m +1 possible values of s . N AIVE -S TRING -M ATCHER ( T , P , n , m ) 1 for s = 0 to n – m 2 if P [1: m ] == T [ s + 1: s + m ] 3 print “Pattern occurs with shift” s Figure 32.3 portrays the naive string-matching procedure as sliding a