Advertisement

An Optimal Algorithm for Online Square Detection

  • Gen-Huey Chen
  • Jin-Ju Hong
  • Hsueh-I Lu
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3537)

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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Apostolico, A., Preparata, F.P.: Optimal off-line dection of repetitions in a string. Theoretical Computer Science 22, 294–315 (1983)CrossRefMathSciNetGoogle Scholar
  2. 2.
    Crochemore, M.: An optimal algorithm for computing the repetitions in a word. Information Processing Letters 12(5), 244–250 (1981)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 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)zbMATHMathSciNetGoogle Scholar
  4. 4.
    Crochemore, M.: Transducers and repetitions. Theoretical Computer Science 45(1), 63–86 (1986)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Gusfield, D.: Algorithms on strings, trees, and sequences: computer science and computational biology. Cambridge University Press, Cambridge (1997)zbMATHCrossRefGoogle Scholar
  6. 6.
    Inenaga, S.: Bidirectional construction of suffix trees. Nordic Journal of Computing 10(1), 52–67 (2003)zbMATHMathSciNetGoogle Scholar
  7. 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)CrossRefGoogle Scholar
  8. 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)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 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. 10.
    Storer, J.A., Szymanski, T.G.: Data compression via textual substitution. Journal of the ACM 29(4), 928–951 (1982)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14(3), 249–260 (1995)zbMATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Gen-Huey Chen
    • 1
  • Jin-Ju Hong
    • 1
  • Hsueh-I Lu
    • 1
  1. 1.Department of Computer Science and Information EngineeringNational Taiwan University 

Personalised recommendations