Online Detection of Repetitions with Backtracking
In this paper we present two algorithms for the following problem: given a string and a rational \(e > 1\), detect in the online fashion the earliest occurrence of a repetition of exponent \(\ge e\) in the string.
1. The first algorithm supports the backtrack operation removing the last letter of the input string. This solution runs in \(O(n\log m)\) time and \(O(m)\) space, where \(m\) is the maximal length of a string generated during the execution of a given sequence of \(n\) read and backtrack operations.
2. The second algorithm works in \(O(n\log \sigma )\) time and \(O(n)\) space, where \(n\) is the length of the input string and \(\sigma \) is the number of distinct letters. This algorithm is relatively simple and requires much less memory than the previously known solution with the same working time and space.
KeywordsRepetition-free Square-free Online algorithm Backtracking
The author would like to thank Arseny M. Shur for the help in the preparation of this paper and Gregory Kucherov for stimulating discussions.
- 8.Kosolobov, D.: Lempel-Ziv factorization may be harder than computing all runs. In: 32nd International Symposium on Theoretical Aspects of Computer Science (STACS 2015). Leibniz International Proceedings in Informatics (LIPIcs), vol. 30, pp. 582–593. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2015)Google Scholar
- 11.Shur, A.M.: Generating square-free words efficiently. Accepted to WORDS 2013 Special Issue of Theoretical Computer Science (2014)Google Scholar
- 12.Thue, A.: Über unendliche zeichenreihen (1906). In: Selected Mathematical Papers of Axel Thue. Universitetsforlaget (1977)Google Scholar
- 13.Weiner, P.: Linear pattern matching algorithms. In: IEEE Conference Record of 14th Annual Symposium on Switching and Automata Theory, SWAT 2008, pp. 1–11. IEEE (1973)Google Scholar