一个例子,其中Knuth-Morris-Pratt算法比Boyer-Moore更快?


Answers:



3

这些模式可以使KMP更快地工作:

T = aaaaaaaaaaaa P = aaaa KMP将尝试10个比较步骤,而Boyer-Moore将采用28个步骤

另一个例子:

T = aaaaaaaaaa P = abab KMP将尝试8个比较步骤,而BM将尝试12个步骤。


在第一个示例中,两种算法都会在第一个班次立即找到匹配项-它们将如何进行4次以上的比较?
BartoszKP
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.