← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 3706.b.1.a.2

转移建表枚举状态与字符

理解等级:中级

直接构造模式匹配自动机时,对每个状态q和输入字符a,从min(m,q+1)向下找最大k,使P[:k]成为P[:q]a的后缀,并置δ(q,a)=k。空串总是后缀,故搜索必会停止。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 第32章 字符串匹配 · 查看原书依据

      The procedure COMPUTE-TRANSITION-FUNCTION on the following page computes the transition function δ from a given pattern P[1:m]. It computes δ(q, a) in a straightforward manner according to its definition in equation (32.4). The nested loops beginning on lines 1 and 2 consider all states q and all characters a, and lines 3–6 set δ(q, a) to be the largest k such that P[:k] ⊐ P[:q]a. The code starts with the largest conceivable value of k, which is q+1, unless q = m, in which

    参考来源

    - 位置:《算法导论(第4版)》第32章《字符串匹配》(OEBPS/chapter032.xhtml,文本字符[30000,35000))。 - 结论依据:原文第32.3–32.4节对应引理、转移表或前缀函数推导;图式已核对。 - 原始内容:The procedure C OMPUTE -T RANSITION -F UNCTION on the following page computes the transition function δ from a given pattern P [1: m ]. It computes δ ( q , a ) in a straightforward manner according to its definition in equation (32.4). The nested loops beginning on lines 1 and 2 consider all states q and all characters a , and lines 3–6 set δ ( q , a ) to be the largest k such that P [: k ] ⊐ P [: q ] a . The code starts with the largest conceivable value of k , which is q +1, unless q = m , in which