CPM 2000: Combinatorial Pattern Matching pp 412-422

# On the Complexity of Determining the Period of a String

• Artur Czumaj
• Leszek Gçasieniec
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1848)

## Abstract

We study the complexity of a classical combinatorial problem of computing the period of a string. We investigate both the average- and the worst-case complexity of the problem.

We deliver almost tight bounds for the average-case. We show that every algorithm computing the period must examine $$\Omega (\sqrt m )$$ symbols of an input string of length m. On the other hand we present an algorithm that computes the period by examining on average $${\rm O}\left( {\sqrt {m \cdot \log _{|\sum |} m} } \right)$$ symbols, where $$\left| \sum \right| \geqslant 2$$ stands for the input alphabet.

We also present a deterministic algorithm that computes the period of a string using m + O(m 3/4) comparisons. This is the first algorithm that have the worst-case complexity m + o(m).

## References

1. 1.
A. V. Aho. Algorithms for finding patterns in strings. In J. van Leeuwen, editor, Handbook of Theoretical Computer Science, Vol. A: Algorithms and Complexity, chapter 5, pages 257–300. Elsevier Science, Amsterdam, 1990.Google Scholar
2. 2.
A. Amir and G. Benson. Two-dimensional periodicity in rectangular arrays. SIAM Journal on Computing, 27(1):90–106, February 1998.Google Scholar
3. 3.
A. Amir, G. Benson, and M. Farach. Alphabet independent two dimensional matching. In Proceedings of the 24th Annual ACM Symposium on Theory of Computing, pages 59–68, Victoria, British Columbia, Canada, May 4–6, 1992. ACM Press, New York, NY.Google Scholar
4. 4.
A. Amir, G. Benson, and M. Farach. An alphabet independent approach to two-dimensional pattern matching. SIAM Journal on Computing, 23(2):313–323, April 1994.Google Scholar
5. 5.
A. Apostolico and M. Crochemore. Optimal canonization of all substrings of a string. Information and Computation, 95(1):76–95, November 1991Google Scholar
6. 6.
A. Apostolico and Z. Galil, editors. Pattern Matching Algorithms. Oxford University Press, New York, NY, 1997.
7. 7.
A. Apostolico and R. Giancarlo. The Boyer-Moore-Galil string searching strategies revisited. SIAM Journal on Computing, 15(1):98–105, February 1986.Google Scholar
8. 8.
R. S. Boyer and J.S. Moore. A fast string searching algorithm. Communications of the ACM, 20:762–772, 1977.
9. 9.
D. Breslauer, L. Colussi, and L. Toniolo. Tight comparison bounds for the string prefix-matching problem. Information Processing Letters, 47(1):51–57, August 1993.Google Scholar
10. 10.
D. Breslauer, L. Colussi, and L. Toniolo. On the comparison complexity of the string prefix-matching problem. Journal of Algorithms, 29(1):18–67, October 1998.Google Scholar
11. 11.
D. Breslauer and Z. Galil. An optimal O(log log n) time parallel string matching algorithm. SIAM Journal on Computing, 19(6):1051–1058, December 1990.Google Scholar
12. 12.
D. Breslauer and Z. Galil. A lower bound for parallel string matching. SIAM Journal on Computing, 21(5):856–862, October 1992. A preliminary version appears in Proceedings of the 23rd Annual ACM Symposium on Theory of Computing, pages 439–443, New Orleans, Louisiana, May 6–8, 1991. ACM Press, New York, NY.Google Scholar
13. 13.
D. Breslauer and Z. Galil. Efficient comparison based string matching. Journal of Complexity, 9(3):339–365, September 1993.Google Scholar
14. 14.
R. Cole. Tight bounds on the complexity of the Boyer-Moore string matching algorithm. SIAM Journal on Computing, 23(5):1075–1091, October 1994.Google Scholar
15. 15.
R. Cole, M. Crochemore, Z. Galil, L. Gçasieniec, R. Hariharan, S. Muthukrishnan, K. Park, and W. Rytter. Optimally fast parallel algorithms for preprocessing and pattern matching in one and two dimensions. In Proceedings of the 34th IEEE Symposium on Foundations of Computer Science, pages 248–258, Palo Alto, CA, November 3–5, 1993. IEEE Computer Society Press, Los Alamitos, CA.Google Scholar
16. 16.
R. Cole and R. Hariharan. Tighter upper bounds on the exact complexity of string matching. SIAM Journal on Computing, 26(3):803–856, June 1997.Google Scholar
17. 17.
R. Cole, R. Hariharan, M. Paterson, and U. Zwick. Tighter lower bounds on the exact complexity of string matching. SIAM Journal on Computing, 24(l):30–45, February 1995.Google Scholar
18. 18.
L. Colussi. Correctness and efficiency of pattern matching algorithms. Information and Computation, 95(2):225–251, December 1991.Google Scholar
19. 19.
L. Colussi, Z. Galil, and R. Giancarlo. On the exact complexity of string matching. In Proceedings of the 22nd Annual ACM Symposium on Theory of Computing, pages 135–144, Baltimore, MD, May 14–16, 1990. ACM Press, New York, NY.Google Scholar
20. 20.
M. Crochemore. Off-line serial exact string searching. In A. Apostolico and Z. Galil, editors, Pattern Matching Algorithms, chapter I, pages 1–53. Oxford University Press, New York, NY, 1997.Google Scholar
21. 21.
M. Crochemore. String-matching on ordered alphabets. Theoretical Computer Science, 92(1):33–47, January 1992Google Scholar
22. 22.
M. Crochemore, A. Czumaj, L. Gçasieniec, S. Jarominek, T. Lecroq, W. Plandowski, and W. Rytter. Speeding up two string-matching algorithms. Algorithmica, 12(4/5):247–267, October 1994.Google Scholar
23. 23.
M. Crochemore, Z. Galil, L. Gçasieniec, K. Park, and W. Rytter. Constant-time randomized parallel string matching. SIAM Journal on Computing, 26(4):950–960, August 1997.Google Scholar
24. 24.
M. Crochemore, L. Gçasieniec, W. Plandowski, and W. Rytter. Two-dimensional pattern matching in linear time and small space. In Proceedings of the 12th Annual Symposium on Theoretical Aspects of Computer Science, volume 900 of Lecture Notes in Computer Science, pages 181–192, Munich, Germany, March 2–4, 1995. Springer-Verlag, Berlin.Google Scholar
25. 25.
M. Crochemore and D. Perrin. Two-way string-matching. Journal of the ACM, 38(3):651–675, July 1991.Google Scholar
26. 26.
M. Crochemore and W. Rytter. Text Algorithms. Oxford University Press, New York, NY, 1994.
27. 27.
A. Czumaj, Z. Galil, L. Gçasieniec, K. Park, and W. Plandowski. Work-time-optimal parallel algorithms for string problems. In Proceedings of the 27th Annual ACM Symposium on Theory of Computing, pages 713–722, Las Vegas, NV, May 29–June 1, 1995. ACM Press, New York, NY.Google Scholar
28. 28.
Z. Galil. Real-time algorithms for string-matching and palindrome recognition. In Proceedings of the 8th Annual ACM Symposium on Theory of Computing, pages 161–173, Hershey, PA, May 3–5, 1976. ACM Press, New York, NY.Google Scholar
29. 29.
Z. Galil. On improving the worst case running time of the Boyer-Moore string matching algorithm. Communications of the ACM, 22(9):505–508, September 1979.Google Scholar
30. 30.
Z. Galil. Optimal parallel algorithms for string matching. Information and Computation, 67(1–3): 144–157, 1985.
31. 31.
Z. Galil and R. Giancarlo. On the exact complexity of string matching: Lower bounds. SIAM Journalon Computing, 20(6): 1008–1020, December 1991.Google Scholar
32. 32.
Z. Galil and K. Park. Alphabet-independent two-dimensional witness computation. SIAM Journalon Computing, 25(5):907–935, October 1996.Google Scholar
33. 33.
Z. Galil and J. Seiferas. Time-space-optimal string matching. Journal of Computer and System Sciences, 26(3):280–294, June 1983.Google Scholar
34. 34.
L. Gçasieniec, W. Plandowski, and W. Rytter. Constant-space string matching with smaller number of comparisons: Sequential sampling. In Z. Galil and E. Ukkonen, editors, Proceedings of the 6th Symposium on Combinatorial Pattern Matching, volume 937 of Lecture Notes in Computer Science, pages 78–89, Espoo, Finland, July 5–7, 1995. Springer-Verlag, Berlin.Google Scholar
35. 35.
L. Gçasieniec, W. Plandowski, and W. Rytter. The zooming method: a recursive approach to time-space efficient string-matching. Theoretical Computer Science, 147(1–2):19–30, August 1995Google Scholar
36. 36.
D. Gusfield. Algorithms on Strings, Trees and Sequences. Cambridge University Press, New York, NY, 1997.
37. 37.
D. E. Knuth, J. H. Morris, and V. R. Pratt. Fast pattern matching in strings. SIAM Journal on Computing, 6(2):323–350, June 1977.Google Scholar
38. 38.
39. 39.
40. 40.
R.C Lyndon and M.P. Schutzenberger. The equation a m = bn cp in a free group, Michigan Math. J., 9: 289–298, 1962.
41. 41.
R. L. Rivest. On the worst case behavior of string searching algorithms. SIAM Journal on Computing, 6(4):669–674, December 1977.Google Scholar
42. 42.
W. Rytter. A correct preprocessing algorithm for Boyer-Moore string-searching. SIAM Journal on Computing, 9(3):509–512, August 1980.Google Scholar
43. 43.
U. Vishkin. Optimal parallel pattern matching in strings. Information and Computation, 67(1-3):91–113, October 1985.Google Scholar
44. 44.
U. Vishkin. Deterministic sampling-a new technique for fast pattern matching. SIAM Journalon Computing, 20(l):22–40, February 1991.Google Scholar
45. 45.
A. C. Yao. The complexity of pattern matching for a random string. SIAM Journal on Computing, 8(3):368–387, August 1979.Google Scholar