Efficient Enumeration of Non-Equivalent Squares in Partial Words with Few Holes

A word of the form WW for some word \(W\in \varSigma ^*\) is called a square, where \(\varSigma \) is an alphabet. A partial word is a word possibly containing holes (also called don’t cares). The hole is a special symbol Open image in new window which matches (agrees with) any symbol from Open image in new window . A p-square is a partial word matching at least one square WW without holes. Two p-squares are called equivalent if they match the same set of squares. We denote by \( psquares (T)\) the number of non-equivalent p-squares which are factors of a partial word T. Let \(\mathrm {PSQUARES}_k(n)\) be the maximum value of \( psquares (T)\) over all partial words of length n with at most k holes. We show asymptotically tight bounds: $$ c_1\cdot \min (nk^2,\, n^2) \le \mathrm {PSQUARES}_k(n) \le c_2\cdot \min (nk^2,\, n^2) $$ for some constants \(c_1,c_2>0\). We also present an algorithm that computes \( psquares (T)\) in \(\mathcal {O}(nk^3)\) time for a partial word T of length n with k holes. In particular, our algorithm runs in linear time for \(k=\mathcal {O}(1)\) and its time complexity near-matches the maximum number of non-equivalent p-square factors in a partial word.

[1]  Wojciech Rytter,et al.  A note on the longest common compatible prefix problem for partial words , 2015, J. Discrete Algorithms.

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

[3]  Francine Blanchet-Sadri,et al.  Computing Primitively-Rooted Squares and Runs in Partial Words , 2014, IWOCA.

[4]  Florin Manea,et al.  Hard Counting Problems for Partial Words , 2010, LATA.

[5]  Florin Manea,et al.  An algorithmic toolbox for periodic partial words , 2014, Discret. Appl. Math..

[6]  Kazuya Tsuruta,et al.  A new characterization of maximal repetitions by Lyndon trees , 2015, SODA.

[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]  Jens Stoye,et al.  Linear time algorithms for finding and representing all the tandem repeats in a string , 2004, J. Comput. Syst. Sci..

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

[10]  Tomasz Kociumaka Minimal Suffix and Rotation of a Substring in Optimal Time , 2016, CPM.

[11]  Tero Harju,et al.  On the number of squares in partial words , 2010, RAIRO Theor. Informatics Appl..

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

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

[14]  Francine Blanchet-Sadri,et al.  Squares in partial words , 2014, Theor. Comput. Sci..

[15]  Lucian Ilie,et al.  A simple proof that a word of length n has at most 2n distinct squares , 2005, J. Comb. Theory A.

[16]  Francine Blanchet-Sadri,et al.  Counting Distinct Squares in Partial Words , 2009, Acta Cybern..

[17]  Francine Blanchet-Sadri,et al.  A note on the number of squares in a partial word with one hole , 2009, RAIRO Theor. Informatics Appl..

[18]  Francine Blanchet-Sadri,et al.  Squares and primitivity in partial words , 2015, Discret. Appl. Math..

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

[20]  Francine Blanchet-Sadri,et al.  The three-squares lemma for partial words with one hole , 2012, Theor. Comput. Sci..

[21]  Florin Manea,et al.  Combinatorial Queries and Updates on Partial Words , 2009, FCT.