Skip to main content
Log in

Squares, cubes, and time-space efficient string searching

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

We address several technical problems related to the time-space optimal string-matching algorithm of Galil and Seiferas (called the GS algorithm). This algorithm contains a parameterk on which the complexity depends and that originally satisfiesk ≥ 4. We show thatk=3 is the least integer for which the GS algorithm works. This value of the parameterk also minimizes the time of the search phase of the string-searching algorithm. With the parameterk=2 we consider a simpler version of the algorithm working in linear time and logarithmic space. This algorithm is based on the following fact: any word of lengthn starts by less than logΦ n squares of primitive prefixes. Fibonacci words have a logarithmic number of square prefixes. Hence, the combinatorics of prefix squares and cubes is essential for string-matching with small memory.

We give a time-space optimal sequential computation of the period of a word based on the GS algorithm. The latter corrects the algorithm given in [GS2] for the computation of periods. We present an optimal parallel algorithm for pattern preprocessing. This paper also provides a cleaner version and a simpler analysis of the GS algorithm.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. A. V. Aho, Algorithms for finding patterns in strings, in: J. van Leeuwen, ed.Handbook of Theoretical Computer Science, vol. A, Elsevier, Amsterdam, 1990, pp. 255–300.

    Google Scholar 

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

    Google Scholar 

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

    Google Scholar 

  4. Z. Galil and J. Seiferas, Saving space in fast string matching,SIAM J. Comput. 9 (1980), 417–438.

    Google Scholar 

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

    Google Scholar 

  6. A. Gibbons and W. Rytter,Efficient Parallel Algorithms, Cambridge University Press, Cambridge, 1988.

    Google Scholar 

  7. D. E. Knuth, J. H. Morris, Jr., and V. R. Pratt, Fast pattern matching in strings,SIAM J. Comput. 6 (1977), 323–350.

    Google Scholar 

  8. M. Lothaire,Combinatorics on Words, Addison-Wesley, Reading, MA, 1983.

    Google Scholar 

  9. I. Simon, Personal communication, 1989.

  10. U. Vishkin, Optimal parallel pattern matching in strings,Inform. and Control 67 (1985), 91–113.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Additional information

Communicated by C. K. Wong.

Work by this author was partially supported by PRC “Mathématiques-Informatique,” by GDR “Informatique et Genome,” and by NATO Grant CRG 900293.

Work by this author was supported by Grant KBN 2-11-90-91-01.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Crochemore, M., Rytter, W. Squares, cubes, and time-space efficient string searching. Algorithmica 13, 405–425 (1995). https://doi.org/10.1007/BF01190846

Download citation

  • Received:

  • Revised:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF01190846

Key words

Navigation