Springer Nature is making SARS-CoV-2 and COVID-19 research free View research | View latest news | Sign up for updates

Optimal parallel detection of squares in strings

  • 81 Accesses

  • 15 Citations

Abstract

A stringw isprimitive if it is not a power of another string (i.e., writingw =v k impliesk = 1. Conversely,w is asquare ifw =vv, withv a primitive string. A stringx issquare-free if it has no nonempty substring of the formww. It is shown that the square-freedom of a string ofn symbols over an arbitrary alphabet can be tested by a CRCW PRAM withn processors inO(logn) time and linear auxiliary space. If the cardinality of the input alphabet is bounded by a constant independent of the input size, then the number of processors can be reduced ton/logn without affecting the time complexity of this strategy. The fastest sequential algorithms solve this problemO(n logn) orO(n) time, depending on whether the cardinality of the input alphabet is unbounded or bounded, and either performance is known to be optimal within its class. More elaborate constructions lead to a CRCW PRAM algorithm for detecting, within the samen-processors bounds, all positioned squares inx in timeO(logn) and using linear auxiliary space. The fastest sequential algorithms solve this problem inO(n logn) time, and such a performance is known to be optimal.

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

References

  1. [1]

    A. Apostolico, On Context-Constrained Squares and Repetitions in a String,RAIRO Inform. Théor. 18 (1984), 147–159.

  2. [2]

    A. Apostolico, M. J. Atallah, L. L. Larmore, and H. S. McFaddin, Efficient Parallel Algorithms for String Editing and Related Problems,SIAM J. Comput. 19(5) (1990), 968–988. Also,Proceedings of the 26th Allerton Conference on Communications, Control and Computing, Monticello, Ill., Sept. 1988, pp. 253–263.

  3. [3]

    A. Apostolico and Z. Galil (eds.),Combinatorial Algorithms on Words, Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985.

  4. [4]

    A. Apostolico, C. Iliopoulos, G. Landau, B. Schieber, and U. Vishkin, Parallel Construction of a Suffix Tree, with Applications,Algorithmica 3 (1988), 347–365.

  5. [5]

    A. Apostolico and F. P. Preparata, Optimal Off-Line Detection of Repetitions in a String,Theoret. Comput. Sci. 22 (1983), 297–315.

  6. [6]

    A. Apostolico and F. P. Preparata. Structural Properties of the String Stratistics ProblemJ. Comput. System. Sci. 31(3) (1985), 394–411.

  7. [7]

    O. Berkman, D. Breslauer, Z, Galil, B. Schieber, and U. Vishkin, Hightly Parallelizable Problems,Proceedings of the 21st ACM Symposium on Theory of Computing, Seattle, Wash., May 1989, pp. 309–319.

  8. [8]

    K. T. Chen, R. H. Fox, and R. C. Lyndon, Free Differential Calculus, IV,Ann. of Math. 68 (1958), 81–95.

  9. [9]

    M. Crochemore, An Optimal Algorithm for Computing the Repetitions in a Word,Inform. Process. Lett. 12(5) (1981), 244–250.

  10. [10]

    M. Crochemore, Recherche Linearire d'un Carré dans un MotC. R. Acad. Sci. Paris Sér. I 296 (1983), 781–784.

  11. [11]

    M. Crochemore and W. Rytter, Usefulness of the Karp-Miller-Rosenberg Strategy in the Design of Parallel Algorithms,Theoret. Comput. Sci. 88 (1991), 59–82.

  12. [12]

    J. P. Duval, Factorizing Words over an Ordered Alphabet,J. Algorithms 4 (1983), 363–381.

  13. [13]

    F. E. Fich, R. L. Ragde, and A. Wigderson, Relations between Concurrent-Write Models of Parallel Computation,Proceedings of the 3rd A CM Symposium on Principles of Distributed Computing, Vancouver, B.C., Aug. 27–29, 1984, pp. 179–184.

  14. [14]

    M. Lothaire,Combinatorics on Words, Addison-Wesley, Reading, Mass., 1982.

  15. [15]

    R. C. Lyndon and M. P. Shutzenberger, The Equationa M = b N c P in a Free Group,Michigan Math. J. 9 (1962), 289–298.

  16. [16]

    M. G. Main and R. J. Lorentz, AnO(n logn) Algorithm for Finding all Repetitions in a String,J. Algorithms 5 (1985), 422–432.

  17. [17]

    M. G. Main and R. J. Lorentz, Linear-Time Recognition of Square-Free Strings, inCombinatorial Algorithms on Words (A. Apostolico and Z. Galil, eds.), Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985, pp. 271–278.

  18. [18]

    M. Rabin, Discovering Repetitions in Strings, inCombinatorial Algorithms on Words (A. Apostolico and Z. Galil, eds), Nato ASI Series F, Vol. 12, Springer-Verlag, Berlin, 1985, pp. 279–288.

  19. [19]

    A. Thue, Über unendliche Zeichenreihen,Norske Vid. Selsk. I Mat. Natur. Kl. Skr., Christiania no. 7 (1906), 1–22.

  20. [20]

    A. Thue, “Über die gegenseitige Lage gleicher Teile gewisser Zeichenreihen”,Norske Vid. Selsk. I Mat.-Natur. Kl. Skr., Christiania no. 1 (1912), 1–67.

  21. [21]

    C. K. Wong and A. K. Chandra, Bounds for the String Editing Problem,J. Assoc. Comput. Mach. 23(1) (1976), 13–16.

Download references

Author information

Additional information

This research was supported, through the Leonardo Fibonacci Institute, by the Istituto Trentino di Cultura, Trento, Italy. Additional support was provided by the French and Italian Ministries of Education, by the National Research Council of Italy, by the British Research Council Grant SERC-E76797, by NSF Grant CCR-89-00305, by NIH Library of Medicine Grant ROI LM05118, by AFOSR Grant 90-0107, and by NATO Grant CRG900293.

Communicated by C. K. Wong.

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Apostolico, A. Optimal parallel detection of squares in strings. Algorithmica 8, 285–319 (1992). https://doi.org/10.1007/BF01758848

Download citation

Key words

  • Parallel computation
  • Combinatorial algorithms on words
  • String matching
  • Avoidable regularities
  • Squares and repetitions in a string