Abstract
We investigate several simple ways of transforming Knuth- Morris-Pratt algorithm (KMP) into a constant-space and still linear time string-matching algorithm. We also identify a class of very special patterns for which the transformation is particularly simple and show usefulness of the class. Constant-space linear-time string-matching algorithms are usually very sophisticated. Most of them consist of two phases: (very technical) preprocessing phase and searching phase. An exception is onephase Crochemore’s algorithm [2]. It is an on-line version of KMP algorithm with “on-the-fly” computation of pattern shifts (as approximate periods). We explore further Crochemore’s approach, and construct alternative algorithms which are differently structured. In Crochemore’s algorithm the approximate-period function is restarted from inside, which means that several internal variables of this function are changing globally, also Crochemore’s algorithm strongly depends on the concrete implementation of approximate-periods computation. We present a simple modification of KMP algorithm which works in O(1)-space, O(n)-time for any function which computes periods or approximate periods in O(1)- space, and linear time. The approximate-period function can be treated as a black box. We show also that lexicographically self-maximal patterns are especially well suited for Crochemore-style string matching. A new O(1) space string-matching algorithm, MaxSuffix-Matching, is proposed in the paper, which gives yet another example of applicability of maximal suffices.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
D. Breslauer, Saving Comparisons in the Crochemore-Perrin String Matching Algorithm. In Proc. of 1st European Symp. on Algorithms, p. 61–72, 1993.
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, Cubes, squares and time space efficient string matching, Algorithmica 13,5 (1995) 405–425
M. Crochemore and W. Rytter, Text algorithms, Oxford University Press, New York, 1994
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. Theoretical Computer Science 1995
L. Gasieniec, W. Plandowski and W. Rytter, String matching in small time and space, Combinatorial Pattern Matching 1995, Lecture Notes in Computer Science 1995
J-P. Duval, Factorizing words over an ordered alphabet, J. Algorithms 4 (1983): 363–381.
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.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2002 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Rytter, W. (2002). On Maximal Suffices and Constant-Space Linear-Time Versions of KMP Algorithm. In: Rajsbaum, S. (eds) LATIN 2002: Theoretical Informatics. LATIN 2002. Lecture Notes in Computer Science, vol 2286. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45995-2_21
Download citation
DOI: https://doi.org/10.1007/3-540-45995-2_21
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-43400-9
Online ISBN: 978-3-540-45995-8
eBook Packages: Springer Book Archive