知识卡片
哈希命中还须逐字符验真
- 模q后的模式与窗口指纹不等即可排除匹配;
- 相等只算一次命中,可能是不同字符串的模碰撞。
拉宾卡普必须再逐字符比较,才能报告真正的有效位移。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第32章 字符串匹配 · 查看原书依据
The solution of working modulo q is not perfect, however: ts = p (mod q) does not automatically mean that ts = p. On the other hand, if ts ≠ p (mod q), then you definitely know that ts ≠ p, so that shift s is invalid. Thus you can use the test ts = p (mod q) as a fast heuristic test to rule out invalid shifts. If ts = p (mod q)—a hit—then you need to test further to see whether s is really valid or you just have a spurious hit. This additional test explicitly
参考来源
- 位置:《算法导论(第4版)》第32章《字符串匹配》(OEBPS/chapter032.xhtml,文本字符[15000,20000))。
- 结论依据:原文第32.2–32.3节对应算法、定义或复杂度说明;公式与示意图已核对。
- 原始内容:The solution of working modulo q is not perfect, however: t s = p (mod q ) does not automatically mean that t s = p . On the other hand, if t s ≠ p (mod q ), then you definitely know that t s ≠ p , so that shift s is invalid. Thus you can use the test t s = p (mod q ) as a fast heuristic test to rule out invalid shifts. If t s = p (mod q )—a hit —then you need to test further to see whether s is really valid or you just have a spurious hit . This additional test explicitly