Fast Practical Multi-Pattern Matching

The multi-pattern matching problem consists in finding all occurrences of the patterns from a finite set X in a given textT of length n. We present a new and simple algorithm combining the ideas of the Aho‐Corasick algorithm and the directed acyclic word graphs. The algorithm has time complexity which is linear in the worst case (it makes at most 2n symbol comparisons) and has good average-case time complexity assuming the shortest pattern is sufficiently long. Denote the length of the shortest pattern bym, and the total length of all patterns by M. Assume thatM is polynomial with respect tom, the alphabet contains at least 2 symbols and the text (in which the pattern is to be found) is random, for each position each letter occurs independently with the same probability. Then the average number of comparisons is O..n=m/ logm/, which matches the lower bound of the problem. For sufficiently large values of m the algorithm has a good behavior in practice. © 1999 Elsevier Science B.V. All rights reserved.