Faster String Matching with Super-Alphabets

  • Authors:
  • Kimmo Fredriksson

  • Affiliations:
  • -

  • Venue:
  • SPIRE 2002 Proceedings of the 9th International Symposium on String Processing and Information Retrieval
  • Year:
  • 2002

Quantified Score

Hi-index 0.00

Visualization

Abstract

Given a text T[1 . . . n] and a pattern P[1 . . . m] over some alphabet 驴 of size 驴, finding the exact occurrences of P in T requires at least 驴(n log驴 m/m) character comparisons on average, as shown in [19]. Consequently, it is believed that this lower bound implies also an 驴(n log驴 m/m) lower bound for the execution time of an optimal algorithm. However, in this paper we show how to obtain an O(n/m) average time algorithm. This is achieved by slightly changing the model of computation, and with a modification of an existing algorithm. Our technique uses a super-alphabet for simulating suffix automaton. The space usage of the algorithm is O(驴m). The technique can be applied to many other string matching algorithms, including dictionary matching, which is also solved in expected time O(n/m), and approximate matching allowing k edit operations (mismatches, insertions or deletions of characters). This is solved in expected time O(nk/m) for k 驴 O(m/log驴 m). The known lower bound for this problem is 驴(n(k + log驴 m)/m), given in [6]. Finally we show how to adopt a similar technique to the shift-or algorithm, extending its bit-parallelism in another direction. This gives a speed-up by a factor s, where s is the number of characters processed simultaneously. Some of the algorithms are implemented, and we show that the methods work well in practice too. This is especially true for the shift-or algorithm, which in some cases works faster than predicted by the theory. The result is the fastest known algorithm for exact string matching for short patterns and small alphabets. All the methods and analyses assume the RAM model of computation, and that each symbol is coded in b = 驴log2 驴驴 bits. They work for larger b too, but the speed-up is decreased.