Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
An O(n log n) algorithm for finding all repetitions in a string
Main M., Lorentz R. Journal of Algorithms5 (3):422-432,1984.Type:Article
Date Reviewed: Jul 1 1985

Given a string of symbols from an alphabet, there are various questions concerning whether the string contains any repetitions; that is, substrings of symbols that are repeated adjacently. The problem of finding all repetitions in an arbitrary string is shown to be solvable in O(nlogn) comparisons where n is the length of the string.

The algorithm is a recursive one based on finding the number of new repetitions that occur when two strings are concatenated. The essence is to show that if these two strings have lengths u and v respectively, then this process can be achieved in O(uv) operations. To do this, a pattern matching algorithm by Knuth, Morris, and Pratt is used [1]. This is combined with the observations that all new repetitions must straddle the join and that new repetitions of equal length will occur in blocks with consecutive starting positions. Hence, an essentially linear search is only necessary for each length.

The algorithms are presented clearly in a logical, easy-to-follow fashion. A comprehensive set of references is given. The notation is helpful. A proof is given that no algorithm based on comparison of symbols with an unspecified length of alphabet can do better than O(nlogn). An alternative method due to Crochemore [2] is referenced. The method of proof also shows that all repetitions of length n/k or greater can be found in O(nlogk) stops. Some remaining problems with finite alphabets and allowing permutations are considered.

Reviewer:  John Slater Review #: CR108964
1) Knuth, D. E.; Morris, J. H., Jr; and Pratt, V. R.Fast pattern matching in strings, SIAM J.Comput. 6 (1977), 323-350.
2) Crochemore, M.Determination optimale des repetitions dans un mot, Tech. Report 80-53, Laboratoire Informatique Theoretique et Programmation, Univ. of Paris, 1981.
Bookmark and Share
 
Pattern Matching (F.2.2 ... )
 
Would you recommend this review?
yes
no
Other reviews under "Pattern Matching": Date
Deterministic sampling
Vishkin U. SIAM Journal on Computing 20(1): 22-40, 1991. Type: Article
Jun 1 1992
Two-way string-matching
Crochemore M., Perrin D. (ed) Journal of the ACM 38(3): 650-674, 1991. Type: Article
Sep 1 1992
On the exact complexity of string matching: lower bounds
Galil Z., Giancarlo R. SIAM Journal on Computing 20(6): 1008-1020, 1991. Type: Article
Jan 1 1993
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy