Skip to main content

An Optimal Algorithm for Online Square Detection

  • Conference paper
Combinatorial Pattern Matching (CPM 2005)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 3537))

Included in the following conference series:

Abstract

A square is the concatenation of two identical non-empty strings. Let S be the input string which is given character by character. Let m be the (unknown) smallest integer such that the m-th prefix of S contains a square. The online square detection problem is to determine m as soon as the m-th character of S is read. The best previously known algorithm of the online square detection problem, due to Leung, Peng, and Ting, runs in O(mlog2 m) time. We improve the time complexity to O(mlog β), where β is the number of distinct characters in the m-th prefix of the input string. It is not difficult to implement our algorithm to run in expected O(m) time.

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 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.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. Apostolico, A., Preparata, F.P.: Optimal off-line dection of repetitions in a string. Theoretical Computer Science 22, 294–315 (1983)

    Article  MathSciNet  Google Scholar 

  2. Crochemore, M.: An optimal algorithm for computing the repetitions in a word. Information Processing Letters 12(5), 244–250 (1981)

    Article  MATH  MathSciNet  Google Scholar 

  3. Crochemore, M.: Recherche linéaire d’un carré dans un mot. Comptes Rendus des Séances de l’Académie des Sciences. Série I. Mathématique 296(18), 781–784 (1983)

    MATH  MathSciNet  Google Scholar 

  4. Crochemore, M.: Transducers and repetitions. Theoretical Computer Science 45(1), 63–86 (1986)

    Article  MATH  MathSciNet  Google Scholar 

  5. Gusfield, D.: Algorithms on strings, trees, and sequences: computer science and computational biology. Cambridge University Press, Cambridge (1997)

    Book  MATH  Google Scholar 

  6. Inenaga, S.: Bidirectional construction of suffix trees. Nordic Journal of Computing 10(1), 52–67 (2003)

    MATH  MathSciNet  Google Scholar 

  7. Leung, H.-F., Peng, Z., Ting, H.-F.: An efficient online algorithm for square detection. In: Chwa, K.-Y., Munro, J.I.J. (eds.) COCOON 2004. LNCS, vol. 3106, pp. 432–439. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  8. Main, M.G., Lorentz, R.J.: An O(n log n) algorithm for finding all repetitions in a string. Journal of Algorithms 5(3), 422–432 (1984)

    Article  MATH  MathSciNet  Google Scholar 

  9. Main, M.G., Lorentz, R.J.: Linear time recognition of squarefree strings. In: Apostolico, A., Galil, Z. (eds.) Combinatorial Algorithms on Words. NATO ASI Series, vol. F12, pp. 271–278. Springer, Heidelberg (1985)

    Google Scholar 

  10. Storer, J.A., Szymanski, T.G.: Data compression via textual substitution. Journal of the ACM 29(4), 928–951 (1982)

    Article  MATH  MathSciNet  Google Scholar 

  11. Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14(3), 249–260 (1995)

    Article  MATH  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Chen, GH., Hong, JJ., Lu, HI. (2005). An Optimal Algorithm for Online Square Detection. In: Apostolico, A., Crochemore, M., Park, K. (eds) Combinatorial Pattern Matching. CPM 2005. Lecture Notes in Computer Science, vol 3537. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11496656_24

Download citation

  • DOI: https://doi.org/10.1007/11496656_24

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-26201-5

  • Online ISBN: 978-3-540-31562-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics