The Number of Repetitions in 2D-Strings

The notions of periodicity and repetitions in strings, and hence these of runs and squares, naturally extend to two-dimensional strings. We consider two types of repetitions in 2D-strings: 2D-runs and quartics (quartics are a 2D-version of squares in standard strings). Amir et al. introduced 2D-runs, showed that there are $O(n^3)$ of them in an $n \times n$ 2D-string and presented a simple construction giving a lower bound of $\Omega(n^2)$ for their number (TCS 2020). We make a significant step towards closing the gap between these bounds by showing that the number of 2D-runs in an $n \times n$ 2D-string is $O(n^2 \log^2 n)$. In particular, our bound implies that the $O(n^2\log n + \textsf{output})$ run-time of the algorithm of Amir et al. for computing 2D-runs is also $O(n^2 \log^2 n)$. We expect this result to allow for exploiting 2D-runs algorithmically in the area of 2D pattern matching. A quartic is a 2D-string composed of $2 \times 2$ identical blocks (2D-strings) that was introduced by Apostolico and Brimkov (TCS 2000), where by quartics they meant only primitively rooted quartics, i.e. built of a primitive block. Here our notion of quartics is more general and analogous to that of squares in 1D-strings. Apostolico and Brimkov showed that there are $O(n^2 \log^2 n)$ occurrences of primitively rooted quartics in an $n \times n$ 2D-string and that this bound is attainable. Consequently the number of distinct primitively rooted quartics is $O(n^2 \log^2 n)$. Here, we prove that the number of distinct general quartics is also $O(n^2 \log^2 n)$. This extends the rich combinatorial study of the number of distinct squares in a 1D-string, that was initiated by Fraenkel and Simpson (J. Comb. Theory A 1998), to two dimensions. Finally, we show some algorithmic applications of 2D-runs. (Abstract shortened due to arXiv requirements.)

[1]  Gary Benson,et al.  An Alphabet Independent Approach to Two-Dimensional Pattern Matching , 1994, SIAM J. Comput..

[2]  Jamie Simpson,et al.  The total run length of a word , 2013, Theor. Comput. Sci..

[3]  Hideo Bannai,et al.  New Lower Bounds for the Maximum Number of Runs in a String , 2008, Stringology.

[4]  M G W H Van De Rijdt,et al.  Two-dimensional Pattern Matching , 2005 .

[5]  Aviezri S. Fraenkel,et al.  How Many Squares Can a String Contain? , 1998, J. Comb. Theory, Ser. A.

[6]  Gad M. Landau,et al.  Double String Tandem Repeats , 2020, CPM.

[7]  Gregory Kucherov,et al.  Finding maximal repetitions in a word in linear time , 1999, 40th Annual Symposium on Foundations of Computer Science (Cat. No.99CB37039).

[8]  Esko Ukkonen,et al.  On-line construction of suffix trees , 1995, Algorithmica.

[9]  Uzi Vishkin,et al.  Optimal Doubly Logarithmic Parallel Algorithms Based on Finding All Nearest Smaller Values , 1993, J. Algorithms.

[10]  H. Wilf,et al.  Uniqueness theorems for periodic functions , 1965 .

[11]  Lucian Ilie,et al.  Analysis of Maximal Repetitions in Strings , 2007, MFCS.

[12]  Amihood Amir,et al.  Efficient 2-dimensional approximate matching of non-rectangular figures , 1991, SODA '91.

[13]  Costas S. Iliopoulos,et al.  A Characterization of the Squares in a Fibonacci String , 1997, Theor. Comput. Sci..

[14]  Frantisek Franek,et al.  How many double squares can a string contain? , 2015, Discret. Appl. Math..

[15]  Amihood Amir,et al.  Repetition Detection in a Dynamic String , 2019, ESA.

[16]  Tomasz Kociumaka,et al.  String synchronizing sets: sublinear-time BWT construction and optimal LCE data structure , 2019, STOC.

[17]  Gad M. Landau,et al.  Two-Dimensional Maximal Repetitions , 2018, ESA.

[18]  Wojciech Rytter,et al.  The Number of Runs in a String: Improved Analysis of the Linear Upper Bound , 2006, STACS.

[19]  Mathieu Giraud,et al.  Not So Many Runs in Strings , 2008, LATA.

[20]  JOHANNES FISCHER,et al.  Beyond the Runs Theorem , 2015, SPIRE.

[21]  Theodore P. Baker A Technique for Extending Rapid Exact-Match String Matching to Arrays of More Than One Dimension , 1978, SIAM J. Comput..

[22]  Wojciech Rytter,et al.  Internal Pattern Matching Queries in a Text and Applications , 2013, SODA.

[23]  Wojciech Rytter,et al.  The number of runs in a string , 2007, Inf. Comput..

[24]  Hideo Bannai,et al.  Computing All Distinct Squares in Linear Time for Integer Alphabets , 2017, CPM.

[25]  William F. Smyth,et al.  How many runs can a string contain? , 2008, Theor. Comput. Sci..

[26]  Maxime Crochemore,et al.  An Optimal Algorithm for Computing the Repetitions in a Word , 1981, Inf. Process. Lett..

[27]  Maxime Crochemore,et al.  Algorithms on strings , 2007 .

[28]  Jamie Simpson Modified Padovan words and the maximum number of runs in a word , 2010, Australas. J Comb..

[29]  M. Lothaire Combinatorics on words, Second Edition , 1997 .

[30]  Lucian Ilie,et al.  Maximal repetitions in strings , 2008, J. Comput. Syst. Sci..

[31]  Kazuya Tsuruta,et al.  The "Runs" Theorem , 2014, SIAM J. Comput..

[32]  Maxime Crochemore,et al.  On the density of Lyndon roots in factors , 2016, Theor. Comput. Sci..

[33]  Dina Sokol,et al.  2D Lyndon Words and Applications , 2015, Algorithmica.

[34]  Wojciech Rytter,et al.  Squares, cubes, and time-space efficient string searching , 1995, Algorithmica.

[35]  Wojciech Rytter,et al.  Counting Distinct Patterns in Internal Dictionary Matching , 2020, CPM.

[36]  Jens Stoye,et al.  Simple and flexible detection of contiguous repeats using a suffix tree , 2002, Theor. Comput. Sci..

[37]  Wojciech Rytter,et al.  Internal Dictionary Matching , 2019, ISAAC.

[38]  Valentin E. Brimkov,et al.  Fibonacci arrays and their two-dimensional repetitions , 2000, Theor. Comput. Sci..

[39]  Jens Stoye,et al.  Linear time algorithms for finding and representing all the tandem repeats in a string , 2004, J. Comput. Syst. Sci..

[40]  Qian Yang,et al.  An asymptotic Lower Bound for the Maximal Number of Runs in a String , 2008, Int. J. Found. Comput. Sci..

[41]  Lucian Ilie,et al.  A note on the number of squares in a word , 2007, Theor. Comput. Sci..

[42]  Wojciech Rytter,et al.  Extracting powers and periods in a word from its runs structure , 2014, Theor. Comput. Sci..

[43]  Valentin E. Brimkov,et al.  Optimal discovery of repetitions in 2D , 2005, Discret. Appl. Math..

[44]  Lucian Ilie,et al.  The "runs" conjecture , 2011, Theor. Comput. Sci..