Abstract
A new string-matching algorithm working in constant space and linear time is presented. It is based on a powerful idea of sampling, originally introduced in parallel computations. The algorithm uses a sample S which consists of two positions inside the pattern P. First the positions of the sample S are tested against the corresponding positions of the text T, then a version of Knuth-Morris-Pratt algorithm is applied. This gives the simplest known string-matching algorithm which works in constant space and linear time and which does not use any linear order of the alphabet. A refined version of the algorithm gives the fastest (in the sense of number of comparisons) known algorithm for string-matching in constant space. It makes (1+ε)n+O(n/m) symbol comparisons. This improves substantially the result of [3], where a (3/2+ε)n comparisons constant space algorithm was designed. Additionally, our preprocessing to this algorithm makes only (1+ε)m+O(1/ε) comparisons and uses constant space.
Supported partially by the KBN grant.
Supported partially by the DFG grant.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
A.V. Aho, Algorithms for Finding Patterns in Strings. In Handbook of Theoretical Computer Science, p. 257–300. Elsevier Science Publishers B. V., Amsterdam, The Netherlands, 1990.
D. Breslauer, private communication.
D. Breslauer, Saving Comparisons in the Crochemore-Perrin String Matching Algorithm. In Proc. of 1st European Symp. on Algorithms, p. 61–72, 1993.
D. Breslauer and Z. Galil, Efficient Comparison Based String Matching. J. Complexity 9(3), p. 339–365, 1993.
R. Cole, R. Hariharan, Tighter bounds on the exact complexity of string matching. In Proc. of 33rd Annual Symp. on Foundations of Comp. Sci., p. 600–609, 1992.
L. Colussi, Correctness and efficiency of string matching algorithms. Inform. and Control, 95, p. 225–251, 1991.
M. Crochemore, L. Gasieniec, W. Plandowski and W. Rytter, Two-dimensional pattern matching in small time and space, in Proc. of STACS'95, Springer-Verlag, 1995.
M. Crochemore, String-matching on ordered alphabets. Theoret. Comput. Sci., 92, p. 33–47, 1992.
M. Crochemore and D. Perrin, Two-way string-matching. J. Assoc. Comput. Mach., 38(3), p. 651–675, 1991.
M. Crochemore and W. Rytter, Periodic Prefixes in Texts. In Proc. of Sequences'91 Workshop ”Sequences II: Methods in Communication, Security and Computer Science”, p. 153–165, Springer-Verlag, 1993.
M. Crochemore and W. Rytter, Text algorithms, Oxford University Press, New York, 1994
Z. Galil and R. Giancarlo, On the exact complexity of string matching: lower bounds. SIAM J. Comput., 20(6), p. 1008–1020, 1991.
Z. Galil and R. Giancarlo, The exact complexity of string matching: upper bounds. SIAM J. Comput., 21(3), p. 407–437, 1992.
Z. Galil and J. Seiferas, Time-space-optimal string matching. J. Comput. System Sci., 26, p. 280–294, 1983.
L. Gasieniec, W. Plandowski and W. Rytter, The zooming method: a recursive approach to time-space efficient string-matching. Theoret. Comput. Sci., to appear.
D.E. Knuth, J.H. Morris and V.R. Pratt, Fast pattern matching in strings. SIAM J. Comput., 6, p. 322–350, 1977.
M. Lothaire, Combinatorics on Words. Addison-Wesley, Reading, MA., U.S.A., 1983.
U. Vishkin, Deterministic sampling — a new technique for fast pattern matching, SIAM J. Comput.,20, p. 22–40, 1991.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1995 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Gasieniec, L., Plandowski, W., Rytter, W. (1995). Constant-space string matching with smaller number of comparisons: sequential sampling. In: Galil, Z., Ukkonen, E. (eds) Combinatorial Pattern Matching. CPM 1995. Lecture Notes in Computer Science, vol 937. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-60044-2_36
Download citation
DOI: https://doi.org/10.1007/3-540-60044-2_36
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-60044-2
Online ISBN: 978-3-540-49412-6
eBook Packages: Springer Book Archive