Skip to main content

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

  • Conference paper
  • First Online:
Computing and Combinatorics (COCOON 2017)

Abstract

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 which matches (agrees with) any symbol from . 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.

P. Charalampopoulos—Supported by the Graduate Teaching Scholarship scheme of the Department of Informatics at King’s College London.

T. Kociumaka—Supported by Polish budget funds for science in 2013–2017 as a research project under the ’Diamond Grant’ program.

J. Radoszewski, W. Rytter and T. Waleń—Supported by the Polish National Science Center, grant no. 2014/13/B/ST6/00770.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Bannai, H., I, T., Inenaga, S., Nakashima, Y., Takeda, M., Tsuruta, K.: A new characterization of maximal repetitions by Lyndon trees. In: Indyk, P. (ed.) 26th Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2015, pp. 562–571. SIAM (2015)

    Google Scholar 

  2. Blanchet-Sadri, F., Bodnar, M., Nikkel, J., Quigley, J.D., Zhang, X.: Squares and primitivity in partial words. Discrete Appl. Math. 185, 26–37 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  3. Blanchet-Sadri, F., Jiao, Y., Machacek, J.M., Quigley, J., Zhang, X.: Squares in partial words. Theor. Comput. Sci. 530, 42–57 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  4. Blanchet-Sadri, F., Mercaş, R.: A note on the number of squares in a partial word with one hole. Inform. Theor. Appl. 43(4), 767–774 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  5. Blanchet-Sadri, F., Mercaş, R.: The three-squares lemma for partial words with one hole. Theor. Comput. Sci. 428, 1–9 (2012)

    Article  MathSciNet  MATH  Google Scholar 

  6. Blanchet-Sadri, F., Mercaş, R., Scott, G.: Counting distinct squares in partial words. Acta Cybern. 19(2), 465–477 (2009)

    MathSciNet  MATH  Google Scholar 

  7. Blanchet-Sadri, F., Nikkel, J., Quigley, J.D., Zhang, X.: Computing primitively-rooted squares and runs in partial words. In: Kratochvíl, J., Miller, M., Froncek, D. (eds.) IWOCA 2014. LNCS, vol. 8986, pp. 86–97. Springer, Cham (2015). doi:10.1007/978-3-319-19315-1_8

    Chapter  Google Scholar 

  8. Crochemore, M., Hancart, C., Lecroq, T.: Algorithms on Strings. Cambridge University Press, Cambridge (2007)

    Book  MATH  Google Scholar 

  9. Crochemore, M., Iliopoulos, C.S., Kociumaka, T., Kubica, M., Langiu, A., Radoszewski, J., Rytter, W., Szreder, B., Waleń, T.: A note on the longest common compatible prefix problem for partial words. J. Discrete Algorithms 34, 49–53 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  10. Crochemore, M., Iliopoulos, C.S., Kubica, M., Radoszewski, J., Rytter, W., Waleń, T.: Extracting powers and periods in a word from its runs structure. Theor. Comput. Sci. 521, 29–41 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  11. Crochemore, M., Rytter, W.: Squares, cubes, and time-space efficient string searching. Algorithmica 13(5), 405–425 (1995)

    Article  MathSciNet  MATH  Google Scholar 

  12. Deza, A., Franek, F., Thierry, A.: How many double squares can a string contain? Discrete Appl. Math. 180, 52–69 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  13. Diaconu, A., Manea, F., Tiseanu, C.: Combinatorial queries and updates on partial words. In: Kutyłowski, M., Charatonik, W., Gębala, M. (eds.) FCT 2009. LNCS, vol. 5699, pp. 96–108. Springer, Heidelberg (2009). doi:10.1007/978-3-642-03409-1_10

    Chapter  Google Scholar 

  14. Fraenkel, A.S., Simpson, J.: How many squares can a string contain? J. Comb. Theory, Ser. A 82(1), 112–120 (1998)

    Article  MathSciNet  MATH  Google Scholar 

  15. Gusfield, D., Stoye, J.: Linear time algorithms for finding and representing all the tandem repeats in a string. J. Comput. Syst. Sci. 69(4), 525–546 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  16. Halava, V., Harju, T., Kärki, T.: On the number of squares in partial words. RAIRO Theor. Inform. Appl. 44(1), 125–138 (2010)

    Article  MathSciNet  MATH  Google Scholar 

  17. Ilie, L.: A simple proof that a word of length \(n\) has at most \(2n\) distinct squares. J. Comb. Theory, Ser. A 112(1), 163–164 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  18. Kociumaka, T.: Minimal suffix and rotation of a substring in optimal time. In: Grossi, R., Lewenstein, M. (eds.) Combinatorial Pattern Matching, CPM 2016. LIPIcs, vol. 54, pp. 28:1–28:12. Schloss Dagstuhl (2016)

    Google Scholar 

  19. Kolpakov, R.M., Kucherov, G.: Finding maximal repetitions in a word in linear time. In: 40th Annual Symposium on Foundations of Computer Science, FOCS 1999, pp. 596–604. IEEE Computer Society (1999)

    Google Scholar 

  20. Manea, F., Mercaş, R., Tiseanu, C.: An algorithmic toolbox for periodic partial words. Discrete Appl. Math. 179, 174–192 (2014)

    Article  MathSciNet  MATH  Google Scholar 

  21. Manea, F., Tiseanu, C.: Hard counting problems for partial words. In: Dediu, A.-H., Fernau, H., Martín-Vide, C. (eds.) LATA 2010. LNCS, vol. 6031, pp. 426–438. Springer, Heidelberg (2010). doi:10.1007/978-3-642-13089-2_36

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Panagiotis Charalampopoulos .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Charalampopoulos, P. et al. (2017). Efficient Enumeration of Non-Equivalent Squares in Partial Words with Few Holes. In: Cao, Y., Chen, J. (eds) Computing and Combinatorics. COCOON 2017. Lecture Notes in Computer Science(), vol 10392. Springer, Cham. https://doi.org/10.1007/978-3-319-62389-4_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-62389-4_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-62388-7

  • Online ISBN: 978-3-319-62389-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics