Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在以下 2 种模式中,哪种模式在 KMP 算法方面表现更好?
模式 1 = PQRSTUV 模式 2 = PPPPPPP
我们必须考虑两种情况
案例1(文本中存在模式1的前缀)
模式 1 和模式 2 给出相同数量的比较
案例2(文本中存在模式2的前缀)
这里模式 1 和模式 2 也给出了相同数量的比较。
所以模式 1 和模式 2 都以相同的方式运行。