ON THE EXACT COMPLEXITY OF STRING MATCHING - UPPER-BOUNDS

被引:26
|
作者
GALIL, Z
GIANCARLO, R
机构
[1] TEL AVIV UNIV, IL-69978 TEL AVIV, ISRAEL
[2] AT&T BELL LABS, MURRAY HILL, NJ 07974 USA
关键词
STRING MATCHING; STRING SEARCHING; TEXT EDITING; COMPUTATIONAL COMPLEXITY; WORST CASE BEHAVIOR;
D O I
10.1137/0221028
中图分类号
TP301 [理论、方法];
学科分类号
081202 ;
摘要
It is shown that, for any pattern of length m and for any text of length n, it is possible to find all occurrences of the pattern in the text in overall linear time and at most 4/3n - 1/3m character comparisons. In fact, the bound on the number of character comparisons is usually tighter than this, for the bound is expressed in terms of the structure of the pattern. The algorithm here need not have any knowledge of the alphabet. This improves the best previous bound of 1.5n -.5(m - 1) obtained by Colussi [Inform. and Comput., to appear] and Apostolico and Crochemore [Tech. Report TR89-75, LITP, Universite de Paris, Paris, France, 1989]. In a companion paper [SIAM J. Comput., 20 (1991), pp. 1008-1020], the authors show a lower bound for on-line algorithms that is equal to 4/3n - 1/3m for m = 3. For m = 1, 2, n character comparisons is optimal. This algorithm is based on a new analysis of the string matching algorithm by Colussi. Moreover, this new analysis of Colussi's algorithm confirms the experimental results showing that his algorithm performs very well in practice [Inform. and Comput., to appear].
引用
收藏
页码:407 / 437
页数:31
相关论文
共 50 条