English

String 2-Covers with No Length Restrictions

Data Structures and Algorithms 2024-05-21 v1

Abstract

A λ\lambda-cover of a string SS is a set of strings {Ci}1λ\{C_i\}_1^\lambda such that every index in SS is contained in an occurrence of at least one string CiC_i. The existence of a 11-cover defines a well-known class of quasi-periodic strings. Quasi-periodicity can be decided in linear time, and all 11-covers of a string can be reported in linear time plus the size of the output. Since in general it is NP-complete to decide whether a string has a λ\lambda-cover, the natural next step is the development of efficient algorithms for 22-covers. Radoszewski and Straszy\'nski [ESA 2020] analysed the particular case where the strings in a 22-cover must be of the same length. They provided an algorithm that reports all such 22-covers of SS in time near-linear in S|S| and in the size of the output. In this work, we consider 22-covers in full generality. Since every length-nn string has Ω(n2)\Omega(n^2) trivial 22-covers (every prefix and suffix of total length at least nn constitute such a 22-cover), we state the reporting problem as follows: given a string SS and a number mm, report all 22-covers {C1,C2}\{C_1,C_2\} of SS with length C1+C2|C_1|+|C_2| upper bounded by mm. We present an O~(n+Output)\tilde{O}(n + Output) time algorithm solving this problem, with Output being the size of the output. This algorithm admits a simpler modification that finds a 22-cover of minimum length. We also provide an O~(n)\tilde{O}(n) time construction of a 22-cover oracle which, given two substrings C1,C2C_1,C_2 of SS, reports in poly-logarithmic time whether {C1,C2}\{C_1,C_2\} is a 22-cover of SS.

Keywords

Cite

@article{arxiv.2405.11475,
  title  = {String 2-Covers with No Length Restrictions},
  author = {Itai Boneh and Shay Golan and Arseny Shur},
  journal= {arXiv preprint arXiv:2405.11475},
  year   = {2024}
}

Comments

31 pages

R2 v1 2026-06-28T16:32:13.202Z