String 2-Covers with No Length Restrictions
Abstract: A $\lambda$-cover of a string $S$ is a set of strings ${C_i}_1\lambda$ such that every index in $S$ is contained in an occurrence of at least one string $C_i$. The existence of a $1$-cover defines a well-known class of quasi-periodic strings. Quasi-periodicity can be decided in linear time, and all $1$-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 $2$-covers. Radoszewski and Straszy\'nski [ESA 2020] analysed the particular case where the strings in a $2$-cover must be of the same length. They provided an algorithm that reports all such $2$-covers of $S$ in time near-linear in $|S|$ and in the size of the output. In this work, we consider $2$-covers in full generality. Since every length-$n$ string has $\Omega(n2)$ trivial $2$-covers (every prefix and suffix of total length at least $n$ constitute such a $2$-cover), we state the reporting problem as follows: given a string $S$ and a number $m$, report all $2$-covers ${C_1,C_2}$ of $S$ with length $|C_1|+|C_2|$ upper bounded by $m$. We present an $\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 $2$-cover of minimum length. We also provide an $\tilde{O}(n)$ time construction of a $2$-cover oracle which, given two substrings $C_1,C_2$ of $S$, reports in poly-logarithmic time whether ${C_1,C_2}$ is a $2$-cover of $S$.
- Computing covers using prefix tables. Discret. Appl. Math., 212:2–9, 2016. URL: https://doi.org/10.1016/j.dam.2015.05.019, doi:10.1016/J.DAM.2015.05.019.
- Can we recover the cover? Algorithmica, 81(7):2857–2875, 2019. URL: https://doi.org/10.1007/s00453-019-00559-8, doi:10.1007/S00453-019-00559-8.
- Approximate cover of strings. Theor. Comput. Sci., 793:59–69, 2019. URL: https://doi.org/10.1016/j.tcs.2019.05.020, doi:10.1016/J.TCS.2019.05.020.
- Efficient detection of quasiperiodicities in strings. Theoretical Computer Science, 119(2):247–265, 1993. URL: https://www.sciencedirect.com/science/article/pii/030439759390159Q, doi:10.1016/0304-3975(93)90159-Q.
- The "runs" theorem. SIAM J. Comput., 46(5):1501–1514, 2017. doi:10.1137/15M1011032.
- Indexing weighted sequences: Neat and efficient. Inf. Comput., 270, 2020. URL: https://doi.org/10.1016/j.ic.2019.104462, doi:10.1016/J.IC.2019.104462.
- The subtree max gap problem with application to parallel string covering. Inf. Comput., 123(1):127–137, 1995. URL: https://doi.org/10.1006/inco.1995.1162, doi:10.1006/INCO.1995.1162.
- Bernard Chazelle. A functional approach to data structures and its use in multidimensional searching. SIAM J. Comput., 17(3):427–462, 1988. doi:10.1137/0217026.
- The complexity of the minimum k-cover problem. Journal of Automata, Languages and Combinatorics, 10(5-6):641–653, 2005.
- Squares, cubes, and time-space efficient string searching. Algorithmica, 13(5):405–425, 1995.
- Experimental evaluation of algorithms for computing quasiperiods. Theoretical Computer Science, 854:17–29, 2021.
- Making data structures persistent. J. Comput. Syst. Sci., 38(1):86–124, 1989. doi:10.1016/0022-0000(89)90034-2.
- Optimal square detection over general alphabets. In Nikhil Bansal and Viswanath Nagarajan, editors, Proceedings of the 2023 ACM-SIAM Symposium on Discrete Algorithms, SODA 2023, Florence, Italy, January 22-25, 2023, pages 5220–5242. SIAM, 2023. URL: https://doi.org/10.1137/1.9781611977554.ch189, doi:10.1137/1.9781611977554.CH189.
- Uniqueness theorems for periodic functions. Proc. Amer. Math. Soc., 16:109–114, 1965.
- Data structures and algorithms for approximate string matching. Journal of Complexity, 4(1):33–72, 1988. doi:10.1016/0885-064X(88)90008-8.
- Quasi-periodicity in streams. In Nadia Pisanti and Solon P. Pissis, editors, 30th Annual Symposium on Combinatorial Pattern Matching, CPM 2019, June 18-20, 2019, Pisa, Italy, volume 128 of LIPIcs, pages 22:1–22:14. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2019. URL: https://doi.org/10.4230/LIPIcs.CPM.2019.22, doi:10.4230/LIPICS.CPM.2019.22.
- Computing the λ𝜆\lambdaitalic_λ-covers of a string. Information Sciences, 177(19):3957–3967, 2007.
- Fast pattern matching in strings. SIAM J. Comput., 6(2):323–350, 1977.
- Fast algorithm for partial covers in words. Algorithmica, 73(1):217–233, 2015. URL: https://doi.org/10.1007/s00453-014-9915-3, doi:10.1007/S00453-014-9915-3.
- Optimal data structure for internal pattern matching queries in a text and applications. CoRR, abs/1311.6235, 2013. URL: http://arxiv.org/abs/1311.6235, arXiv:1311.6235.
- Fast string matching with k differences. Journal of Computer and System Sciences, 37(1):63–78, 1988. doi:10.1016/0022-0000(88)90045-1.
- Suffix tree-based linear algorithms for multiple prefixes, single suffix counting and listing problems. CoRR, abs/2203.16908, 2022. URL: https://doi.org/10.48550/arXiv.2203.16908, arXiv:2203.16908, doi:10.48550/ARXIV.2203.16908.
- An optimal algorithm to compute all the covers of a string. Information Processing Letters, 50(5):239–246, 1994. URL: https://www.sciencedirect.com/science/article/pii/002001909400045X, doi:10.1016/0020-0190(94)00045-X.
- A correction to “an optimal algorithm to compute all the covers of a string”. Information Processing Letters, 54(2):101–103, 1995. URL: https://www.sciencedirect.com/science/article/pii/002001909400235Q, doi:10.1016/0020-0190(94)00235-Q.
- An output-sensitive algorithm for the minimization of 2-dimensional string covers. In T. V. Gopal and Junzo Watada, editors, Theory and Applications of Models of Computation - 15th Annual Conference, TAMC 2019, Kitakyushu, Japan, April 13-16, 2019, Proceedings, volume 11436 of Lecture Notes in Computer Science, pages 536–549. Springer, 2019. doi:10.1007/978-3-030-14812-6\_33.
- Efficient computation of 2-covers of a string. In 28th Annual European Symposium on Algorithms (ESA 2020). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2020.
- Counting palindromes in substrings. In Gabriele Fici, Marinella Sciortino, and Rossano Venturini, editors, String Processing and Information Retrieval - 24th International Symposium, SPIRE 2017, Proceedings, volume 10508 of Lecture Notes in Computer Science, pages 290–303. Springer, 2017.
- Smyth. Computing the cover array in linear time. Algorithmica, 32:95–106, 2002.
- Dan E. Willard. New data structures for orthogonal range queries. SIAM J. Comput., 14(1):232–253, 1985. doi:10.1137/0214019.
- Algorithms for computing the λ𝜆\lambdaitalic_λ-regularities in strings. Fundamenta Informaticae, 84(1):33–49, 2008.
Paper Prompts
Sign up for free to create and run prompts on this paper using GPT-5.
Top Community Prompts
Collections
Sign up for free to add this paper to one or more collections.