Document Open Access Logo

On Strings Having the Same Length- k Substrings

Authors Giulia Bernardini , Alessio Conte, Esteban Gabory, Roberto Grossi, Grigorios Loukides , Solon P. Pissis , Giulia Punzi, Michelle Sweering

Thumbnail PDF


  • Filesize: 0.9 MB
  • 17 pages

Document Identifiers

Author Details

Giulia Bernardini
  • University of Trieste, Italy
  • CWI, Amsterdam, The Netherlands
Alessio Conte
  • University of Pisa, Italy
Esteban Gabory
  • CWI, Amsterdam, The Netherlands
Roberto Grossi
  • University of Pisa, Italy
Grigorios Loukides
  • King’s College London, UK
Solon P. Pissis
  • CWI, Amsterdam, The Netherlands
  • Vrije Universiteit, Amsterdam, The Netherlands
Giulia Punzi
  • University of Pisa, Italy
Michelle Sweering
  • CWI, Amsterdam, The Netherlands

Cite AsGet BibTex

Giulia Bernardini, Alessio Conte, Esteban Gabory, Roberto Grossi, Grigorios Loukides, Solon P. Pissis, Giulia Punzi, and Michelle Sweering. On Strings Having the Same Length- k Substrings. In 33rd Annual Symposium on Combinatorial Pattern Matching (CPM 2022). Leibniz International Proceedings in Informatics (LIPIcs), Volume 223, pp. 16:1-16:17, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2022)


Let Substr_k(X) denote the set of length-k substrings of a given string X for a given integer k > 0. We study the following basic string problem, called z-Shortest 𝒮_k-Equivalent Strings: Given a set 𝒮_k of n length-k strings and an integer z > 0, list z shortest distinct strings T₁,…,T_z such that Substr_k(T_i) = 𝒮_k, for all i ∈ [1,z]. The z-Shortest 𝒮_k-Equivalent Strings problem arises naturally as an encoding problem in many real-world applications; e.g., in data privacy, in data compression, and in bioinformatics. The 1-Shortest 𝒮_k-Equivalent Strings, referred to as Shortest 𝒮_k-Equivalent String, asks for a shortest string X such that Substr_k(X) = 𝒮_k. Our main contributions are summarized below: - Given a directed graph G(V,E), the Directed Chinese Postman (DCP) problem asks for a shortest closed walk that visits every edge of G at least once. DCP can be solved in 𝒪̃(|E||V|) time using an algorithm for min-cost flow. We show, via a non-trivial reduction, that if Shortest 𝒮_k-Equivalent String over a binary alphabet has a near-linear-time solution then so does DCP. - We show that the length of a shortest string output by Shortest 𝒮_k-Equivalent String is in 𝒪(k+n²). We generalize this bound by showing that the total length of z shortest strings is in 𝒪(zk+zn²+z²n). We derive these upper bounds by showing (asymptotically tight) bounds on the total length of z shortest Eulerian walks in general directed graphs. - We present an algorithm for solving z-Shortest 𝒮_k-Equivalent Strings in 𝒪(nk+n²log²n+zn²log n+|output|) time. If z = 1, the time becomes 𝒪(nk+n²log²n) by the fact that the size of the input is Θ(nk) and the size of the output is 𝒪(k+n²).

Subject Classification

ACM Subject Classification
  • Theory of computation → Pattern matching
  • string algorithms
  • combinatorics on words
  • de Bruijn graph
  • Chinese Postman


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Laura Barker, Pamela Fleischmann, Katharina Harwardt, Florin Manea, and Dirk Nowotka. Scattered factor-universality of words. In Developments in Language Theory - 24th International Conference, volume 12086 of Lecture Notes in Computer Science, pages 14-28. Springer, 2020. URL:
  2. Giulia Bernardini, Huiping Chen, Gabriele Fici, Grigorios Loukides, and Solon P. Pissis. Reverse-safe data structures for text indexing. In Proceedings of the Symposium on Algorithm Engineering and Experiments, ALENEX, pages 199-213, 2020. URL:
  3. Giulia Bernardini, Huiping Chen, Gabriele Fici, Grigorios Loukides, and Solon P. Pissis. Reverse-safe text indexing. ACM J. Exp. Algorithmics, 26, 2021. URL:
  4. Bastien Cazaux, Thierry Lecroq, and Eric Rivals. Linking indexing data structures to de Bruijn graphs: Construction and update. J. Comput. Syst. Sci., 104:165-183, 2019. URL:
  5. Alessio Conte, Roberto Grossi, Grigorios Loukides, Nadia Pisanti, Solon P. Pissis, and Giulia Punzi. Beyond the BEST theorem: Fast assessment of Eulerian trails. In Fundamentals of Computation Theory - 23rd International Symposium,, volume 12867 of Lecture Notes in Computer Science, pages 162-175. Springer, 2021. URL:
  6. Maxime Crochemore, Christophe Hancart, and Thierry Lecroq. Algorithms on strings. Cambridge University Press, 2007. Google Scholar
  7. Maxime Crochemore, Borivoj Melichar, and Zdenek Tronícek. Directed acyclic subsequence graph - overview. J. Discrete Algorithms, 1(3-4):255-280, 2003. URL:
  8. Jack R. Edmonds and Ellis L. Johnson. Matching, Euler tours and the Chinese Postman. Math. Program., 5(1):88-124, 1973. URL:
  9. Leonhard Euler. Solutio problematis ad geometriam situs pertinentis. Euler Archive - All Works, 53:15, 1741. Google Scholar
  10. Lukas Fleischer and Manfred Kufleitner. Testing Simon’s congruence. In 43rd International Symposium on Mathematical Foundations of Computer Science, volume 117 of LIPIcs, pages 62:1-62:13. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2018. URL:
  11. Emmanuelle Garel. Minimal separators of two words. In Combinatorial Pattern Matching, 4th Annual Symposium, volume 684 of Lecture Notes in Computer Science, pages 35-53. Springer, 1993. URL:
  12. Pawel Gawrychowski, Maria Kosche, Tore Koß, Florin Manea, and Stefan Siemer. Efficiently testing Simon’s congruence. In 38th International Symposium on Theoretical Aspects of Computer Science,, volume 187 of LIPIcs, pages 34:1-34:18. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2021. URL:
  13. Andrew V. Goldberg and Robert Endre Tarjan. Solving minimum-cost flow problems by successive approximation. In Alfred V. Aho, editor, Proceedings of the 19th Annual ACM Symposium on Theory of Computing, pages 7-18. ACM, 1987. URL:
  14. Horst W. Hamacher. A note on K best network flows. Ann. Oper. Res., 57(1):65-72, 1995. URL:
  15. Jean-Jacques Hébrard. An algorithm for distinguishing efficiently bit-strings by their subsequences. Theor. Comput. Sci., 82(1):35-49, 1991. URL:
  16. Joan P. Hutchinson. On words with prescribed overlapping subsequences. Utilitas Mathematica, 7:241-250, 1975. Google Scholar
  17. Joan P. Hutchinson and Herbert S. Wilf. On Eulerian circuits and words with prescribed adjacency patterns. J. Comb. Theory, Ser. A, 18(1):80-87, 1975. URL:
  18. Prateek Karandikar, Manfred Kufleitner, and Philippe Schnoebelen. On the index of Simon’s congruence for piecewise testability. Inf. Process. Lett., 115(4):515-519, 2015. URL:
  19. Prateek Karandikar and Philippe Schnoebelen. The height of piecewise-testable languages with applications in logical complexity. In 25th EACSL Annual Conference on Computer Science Logic, volume 62 of LIPIcs, pages 37:1-37:22. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2016. URL:
  20. Prateek Karandikar and Philippe Schnoebelen. The height of piecewise-testable languages and the complexity of the logic of subwords. Log. Methods Comput. Sci., 15(2), 2019. URL:
  21. Juhani Karhumäki, Svetlana Puzynina, Michaël Rao, and Markus A. Whiteland. On cardinalities of k-abelian equivalence classes. Theor. Comput. Sci., 658:190-204, 2017. URL:
  22. Carl Kingsford, Michael C. Schatz, and Mihai Pop. Assembly complexity of prokaryotic genomes using short reads. BMC Bioinform., 11:21, 2010. URL:
  23. David Könen, Daniel R. Schmidt, and Christiane Spisla. Finding all minimum cost flows and a faster algorithm for the K best flow problem. CoRR, abs/2105.10225, 2021. URL:
  24. Kazuhiro Kurita and Kunihiro Wasa. Constant amortized time enumeration of Eulerian trails. CoRR, abs/2101.10473, 2021. URL:
  25. M. Lothaire. Combinatorics on Words. Cambridge Mathematical Library. Cambridge University Press, 2nd edition, 1997. URL:
  26. Alessio Orlandi and Rossano Venturini. Space-efficient substring occurrence estimation. Algorithmica, 74(1):65-90, 2016. URL:
  27. James B. Orlin. A faster strongly polynomial minimum cost flow algorithm. Oper. Res., 41(2):338-350, 1993. URL:
  28. James B. Orlin. A polynomial time primal network simplex algorithm for minimum cost flows. Math. Program., 77:109-129, 1997. URL:
  29. Pavel A. Pevzner, Haixu Tang, and Michael S. Waterman. An Eulerian path approach to DNA fragment assembly. Proc Natl Acad Sci, 98(17):9748-9753, 2001. URL:
  30. Antonio Sedeño-Noda and Juan José Espino-Martín. On the K best integer network flows. Comput. Oper. Res., 40(2):616-626, 2013. URL:
  31. Imre Simon. Piecewise testable events. In Automata Theory and Formal Languages, 2nd GI Conference, volume 33 of Lecture Notes in Computer Science, pages 214-222. Springer, 1975. URL:
  32. Robert Endre Tarjan. Dynamic trees as search trees via Euler tours, applied to the network simplex algorithm. Math. Program., 77:169-177, 1997. URL:
  33. Zdenek Tronícek. Common subsequence automaton. In Implementation and Application of Automata, 7th International Conference, volume 2608 of Lecture Notes in Computer Science, pages 270-275. Springer, 2002. URL:
  34. Tatyana van Aardenne-Ehrenfest and Nicolaas G. de Bruijn. Circuits and trees in oriented linear graphs. In Ira Gessel and Gian-Carlo Rota, editors, Classic Papers in Combinatorics, pages 149-163. Birkhäuser Boston, Boston, MA, 1987. URL:
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail