On the Practical Power of Automata in Pattern Matching

07/17/2022
by   Ora Amir, et al.
0

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 Σ. 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 KMP-automaton, has proven useful in solving many other problems. A notable example is the parameterized pattern matching model. In this model, a consistent renaming of symbols from Σ 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.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
12/18/2020

The Parameterized Suffix Tray

Let Σ and Π be disjoint alphabets, respectively called the static alphab...
research
06/19/2023

Efficient Parameterized Pattern Matching in Sublinear Space

The parameterized matching problem is a variant of string matching, whic...
research
02/01/2019

Linear-size Suffix Tries for Parameterized Strings

In this paper, we propose a new indexing structure for parameterized str...
research
08/05/2019

Heuristic Algorithm for Generalized Function Matching

The problem of generalized function matching can be defined as follows: ...
research
02/27/2022

Parallel algorithm for pattern matching problems under substring consistent equivalence relations

Given a text and a pattern over an alphabet, the pattern matching proble...
research
07/28/2022

Engineering faster double-array Aho-Corasick automata

Multiple pattern matching in strings is a fundamental problem in text pr...
research
08/11/2023

Breaking a Barrier in Constructing Compact Indexes for Parameterized Pattern Matching

A parameterized string (p-string) is a string over an alphabet (Σ_s∪Σ_p)...

Please sign up or login with your details

Forgot password? Click here to reset