The classical pattern matching paradigm is that of seeking occurrences of one string - the pattern, in another - the text, where both strings are drawn from an alphabet set $\Sigma$. Assuming the text length is $n$ and the pattern length is $m$, this problem can naively be solved in time $O(nm)$. In Knuth, Morris and Pratt's seminal paper of 1977, an automaton, was developed that allows solving this problem in time $O(n)$ for any alphabet. This automaton, which we will refer to as the {\em KMP-automaton}, has proven useful in solving many other problems. A notable example is the {\em parameterized pattern matching} model. In this model, a consistent renaming of symbols from $\Sigma$ is allowed in a match. The parameterized matching paradigm has proven useful in problems in software engineering, computer vision, and other applications. It has long been suspected that for texts where the symbols are uniformly random, the naive algorithm will perform as well as the KMP algorithm. In this paper we examine the practical efficiency of the KMP algorithm vs. the naive algorithm on a randomly generated text. We analyse the time under various parameters, such as alphabet size, pattern length, and the distribution of pattern occurrences in the text. We do this for both the original exact matching problem and parameterized matching. While the folklore wisdom is vindicated by these findings for the exact matching case, surprisingly, the KMP algorithm works significantly faster than the naive in the parameterized matching case. We check this hypothesis for DNA texts, and observe a similar behaviour as in the random text. We also show a very structured case where the automaton is much more efficient.
翻译:经典模式匹配范式的典型模式是寻找一个字符串的出现 — 在另一个字符串的格局中, 在另一个文本中, 两种字符串都是用字母设置的 $\ sigma$ 。 假设文本长度为 $n美元, 模式长度为 $ 美元, 这个问题可以天真地在时间上解决 $O( n) 美元。 在Knuth, Morris 和 Pratt 的1977 的原始文件“ 自动图案 ” 中, 开发了一种能够及时解决任何字母使用O( n) 美元问题的典型模式。 这个“ 直观”, 我们称之为 $ em KMP- automaton}, 已经证明它对于解决许多其他问题的都有用。 一个显著的例子是 : 文本的自动图案, 我们用直径直径直的直线算算法, 我们用直径直线算法的比KMP 运算法, 我们用直径直径的比直径的直径比直径, 。 我们用直径直径直地分析KMP 运算法, 我们用直径比直径算法的直径直径直径直地算法, 我们用直径直判判判判判的直判判判判, 。
Alphabet is mostly a collection of companies. This newer Google is a bit slimmed down, with the companies that are pretty far afield of our main internet products contained in Alphabet instead.https://abc.xyz/