algorithm - KMP 字符串搜索算法的最坏情况是什么?

标签 algorithm testing complexity-theory

<分区>

任何人都可以向我建议用于测试 KMP 算法实现的最坏情况“文本字符串 - 模式对”吗?

最佳答案

我会说这样的模式

xx........x
| n times |

和一个类似的字符串

xxx.........xyx...........xy....
| n-1 times | | n-1 times |

将是最坏的情况之一,但它仍然是 O(m+n)

关于algorithm - KMP 字符串搜索算法的最坏情况是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7839165/

相关文章:

java - 将红黑树转换为 AVL 树

perl - 我们如何使用 Test2::V0 测试可选的哈希字段

grails - 如何在 Grails 应用程序中运行 Geb 测试套件

c - 这个循环的时间复杂度是O(n^2)吗?

algorithm - 有人可以解释广度优先搜索吗?

algorithm - 创建动态父子关系

数与大于其平方根的最小素数在素数列表中的位置之间的关系

ruby-on-rails - factory_girl vs fixtures for development data (Rails)

algorithm - 桶排序 :Why don't we set range to 1? vs 计数排序

python - for 循环内部或外部 if 语句的复杂性