English

Efficient Algorithms to Compute Closed Substrings

Data Structures and Algorithms 2026-01-12 v3

Abstract

A closed string uu is either of length one or contains a border that occurs only as a prefix and as a suffix in uu and nowhere else within uu. In this paper, we present fast O(nlogn)\mathcal{O}(n\log n) time algorithms to compute all O(n2)\mathcal{O}(n^2) closed substrings by introducing a compact representation for all closed substrings of a string w[1..n] w[1..n], using only O(nlogn)\mathcal{O}(n \log n) space. These simple and space-efficient algorithms also compute maximal closed strings. Furthermore, we compare the performance of these algorithms and identify classes of strings where each performs best. Finally, we show that the exact number of MCSs (M(fn)M(f_n)) in a Fibonacci word fn f_n , for n5n \geq 5, is (1+1ϕ2)Fn1.382Fn\approx \left(1 + \frac{1}{\phi^2}\right) F_n \approx 1.382 F_n, where ϕ \phi is the golden ratio.

Keywords

Cite

@article{arxiv.2506.06452,
  title  = {Efficient Algorithms to Compute Closed Substrings},
  author = {Samkith K Jain and Neerja Mhaskar},
  journal= {arXiv preprint arXiv:2506.06452},
  year   = {2026}
}

Comments

Submitted to TOCS 2026