← 返回卡片

原书出处

Introduction to Algorithms, Fourth Edition

32 第32章 字符串匹配

Fourth edition · 核验版本的摘录快照 · 导入于 2026-10-23T08:18:08.766Z

while loop terminates. After line 7 increments q, the new state number q equals σ(T[:i]).

Line 10 is necessary in KMP-MATCHER, because otherwise, line 4 might try to reference P[m + 1] after finding an occurrence of P. (The argument that q = σ(T[:i – 1]) upon the next execution of line 4 remains valid by the hint given in Exercise 32.4-8: that δ(m, a) = δ(π[m], a) or, equivalently, σ(Pa) = σ(P[:π[m]]a) for any a ∈ ∑.) The remaining argument for the correctness of the Knuth-Morris-Pratt algorithm follows from the correctness of FINITE-AUTOMATON-MATCHER,

since we have shown that KMP-MATCHER simulates the behavior of FINITE-AUTOMATON-MATCHER.

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Introduction to Algorithms, Fourth Edition/_epub-src/OEBPS/chapter032.xhtml

EPUB SHA-256:ec7ced04bb875b93983816aef7a667855a4b71c5cf53b63406b9439c74e27aea