Skip to main content

On Maximal Suffices and Constant-Space Linear-Time Versions of KMP Algorithm

  • Conference paper
  • First Online:
LATIN 2002: Theoretical Informatics (LATIN 2002)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2286))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. D. Breslauer, Saving Comparisons in the Crochemore-Perrin String Matching Algorithm. In Proc. of 1st European Symp. on Algorithms, p. 61–72, 1993.

    Google Scholar 

  2. M. Crochemore, String-matching on ordered alphabets. Theoret. Comput. Sci., 92, p. 33–47, 1992.

    Article  MathSciNet  Google Scholar 

  3. M. Crochemore and D. Perrin, Two-way string-matching. J. Assoc. Comput. Mach., 38(3), p. 651–675, 1991.

    Article  MathSciNet  Google Scholar 

  4. M. Crochemore and W. Rytter, Cubes, squares and time space efficient string matching, Algorithmica 13,5 (1995) 405–425

    Article  MathSciNet  Google Scholar 

  5. M. Crochemore and W. Rytter, Text algorithms, Oxford University Press, New York, 1994

    MATH  Google Scholar 

  6. Z. Galil and J. Seiferas, Time-space-optimal string matching. J. Comput. System Sci., 26, p. 280–294, 1983.

    Article  MathSciNet  Google Scholar 

  7. L. Gasieniec, W. Plandowski and W. Rytter, The zooming method: a recursive approach to time-space efficient string-matching. Theoretical Computer Science 1995

    Google Scholar 

  8. L. Gasieniec, W. Plandowski and W. Rytter, String matching in small time and space, Combinatorial Pattern Matching 1995, Lecture Notes in Computer Science 1995

    MATH  Google Scholar 

  9. J-P. Duval, Factorizing words over an ordered alphabet, J. Algorithms 4 (1983): 363–381.

    Article  MathSciNet  Google Scholar 

  10. D.E. Knuth, J.H. Morris and V.R. Pratt, Fast pattern matching in strings. SIAM J. Comput., 6, p. 322–350, 1977.

    Article  MathSciNet  Google Scholar 

  11. M. Lothaire, Combinatorics on Words. Addison-Wesley, Reading, MA., U.S.A., 1983.

    MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics