【发布时间】:2012-11-27 08:16:50
【问题描述】:
我正在阅读关于 KMP 的字符串匹配。
它需要通过构建前缀表对模式进行预处理。
例如对于字符串ababaca,前缀表是:P = [0, 0, 1, 2, 3, 0, 1]
但我不清楚这些数字显示了什么。我读到它有助于在模式变化时找到匹配的模式,但我无法将此信息与表中的数字联系起来。
【问题讨论】:
-
Prefix Table在KMP算法中也称为Partial Match Table。这个博客解释得很漂亮 - The Knuth-Morris-Pratt Algorithm in my own words
标签: string algorithm data-structures pattern-matching