A Minimal Periods Algorithm with Applications

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


Kosaraju in “Computation of squares in a string” briefly described a linear-time algorithm for computing the minimal squares starting at each position in a word. Using the same construction of suffix trees, we generalize his result and describe in detail how to compute the minimal α power, with a period of length longer than s, starting at each position in a word w for arbitrary exponent α> 1 and integer s ≥ 0. The algorithm runs in O(α|w|)-time for s = 0 and in O(|w|2)-time otherwise. We provide a complete proof of the correctness and computational complexity of the algorithm. The algorithm can be used to detect certain types of pseudo-patterns in words, which was our original goal in studying this generalization.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Apostolico, A., Preparata, F.P.: Optimal off-line detection of repetitions in a string. Theoret. Comput. Sci. 22, 297–315 (1983)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Beauquier, D., Nivat, M.: On translating one polyomino to tile the plane. Discrete Comput. Geom. 6(1), 575–592 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Chiniforooshan, E., Kari, L., Xu, Z.: Pseudo-power avoidance. CoRR abs/0911. 2233 (2009),
  4. 4.
    Crochemore, M.: Optimal algorithm for computing the repetitions in a word. Info. Proc. Lett. 12(5), 244–250 (1981)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Crochemore, M.: Recherche linéaire d’un carré dans un mot. Comptes Rendus Acad. Sci. Paris Sér. I 296, 781–784 (1983)zbMATHMathSciNetGoogle Scholar
  6. 6.
    Crochemore, M., Ilie, L., Rytter, W.: Repetitions in strings: Algorithms and combinatorics. Theoret. Comput. Sci. 410(50), 5227–5235 (2009)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Duval, J., Kolpakov, R., Kucherov, G., Lecroq, T., Lefebvre, A.: Linear-time computation of local periods. Theoret. Comput. Sci. 326, 229–240 (2004)zbMATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Fraenkel, A.S., Simpson, J.: How many squares can a string contain? J. Combin. Theory Ser. A 82(1), 112–120 (1998)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Gusfield, D.: Algorithms on strings, trees, and sequences: computer science and computational biology. Cambridge University Press, Cambridge (1997)zbMATHGoogle Scholar
  10. 10.
    Gusfield, D., Stoye, J.: Linear time algorithms for finding and representing all the tandem repeats in a string. J. Comput. Syst. Sci. 69(4), 525–546 (2004)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestors. SIAM J. Comput. 13(2), 338–355 (1984)zbMATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Ilie, L.: A note on the number of squares in a word. Theoret. Comput. Sci. 380(3), 373–376 (2007)zbMATHCrossRefMathSciNetGoogle Scholar
  13. 13.
    Knuth, D., Morris, J., Pratt, V.: Fast pattern matching in strings. SIAM J. Comput. 6(2), 323–350 (1977)zbMATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Kolpakov, R., Kucherov, G.: Finding maximal repetitions in a word in linear time. In: Proc. 40th Ann. Symp. Found. Comput. Sci (FOCS 1999), pp. 596–604. IEEE Computer Society Press, Los Alamitos (1999)Google Scholar
  15. 15.
    Kosaraju, S.R.: Computation of squares in a string. In: Crochemore, M., Gusfield, D. (eds.) Proc. 5th Combinat. Patt. Matching, pp. 146–150. Springer, Heidelberg (1994)Google Scholar
  16. 16.
    Main, M., Lorentz, R.: An O(nlogn) algorithm for finding all repetitions in a string. J. Algorithms 5(3), 422–432 (1984)zbMATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Main, M., Lorentz, R.: Linear time recognition of square free strings. In: Apostolico, A., Galil, Z. (eds.) Combinat. Algor. on Words, pp. 272–278. Springer, Heidelberg (1985)Google Scholar
  18. 18.
    Main, M.G.: Detecting leftmost maximal periodicities. Discrete Appl. Math. 25(1–2), 145–153 (1989)zbMATHCrossRefMathSciNetGoogle Scholar
  19. 19.
    McCreight, E.M.: A space-economical suffix tree construction algorithm. J. Assoc. Comput. Mach. 23(2), 262–272 (1976)zbMATHMathSciNetGoogle Scholar
  20. 20.
    Schieber, B., Vishkin, U.: On finding lowest common ancestors: Simplification and parallelization. SIAM J. Comput. 17(6), 1253–1262 (1988)zbMATHCrossRefMathSciNetGoogle Scholar
  21. 21.
    Slisenko, A.O.: Detection of periodicities and string-matching in real time. J. Math. Sci (N. Y.) 22(3), 1316–1387 (1983)zbMATHCrossRefGoogle Scholar
  22. 22.
    Stoye, J., Gusfield, D.: Simple and flexible detection of contiguous repeats using a suffix tree preliminary version. In: Farach-Colton, M. (ed.) Proc. 9th Combinat. Patt. Matching, pp. 140–152. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  23. 23.
    Thue, A.: Über unendliche Zeichenreihen. Norske Vid. Selsk. Skr. I. Mat.-Nat. Kl (7), 1–22 (1906)Google Scholar
  24. 24.
    Ukkonen, E.: Constructing suffix trees on-line in linear time. In: Leeuwen, J.V. (ed.) Proc. Infor. Proces. 92, IFIP Trans. A-12., Vol. 1. pp. 484–492. Elsevier, Amsterdam (1992)Google Scholar
  25. 25.
    Weiner, P.: Linear pattern matching algorithms. In: Proc. 14th IEEE Ann. Symp. on Switching and Automata Theory (SWAT), pp. 1–11 (1973)Google Scholar
  26. 26.

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Zhi Xu
    • 1
  1. 1.Department of Computer Science, Middlesex CollegeThe University of Western OntarioLondonCanada

Personalised recommendations