A closed string $u$ is either of length one or contains a border that occurs only as a prefix and as a suffix in $u$ and nowhere else within $u$. In this paper, we present fast $\mathcal{O}(n\log n)$ time algorithms to compute all $\mathcal{O}(n^2)$ closed substrings by introducing a compact representation for all closed substrings of a string $ w[1..n]$, using only $\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(f_n)$) in a Fibonacci word $ f_n $, for $n \geq 5$, is $\approx \left(1 + \frac{1}{φ^2}\right) F_n \approx 1.382 F_n$, where $ φ$ is the golden ratio.
翻译:闭合字符串$u$要么长度为1,要么包含一个仅作为前缀和后缀出现、且不在$u$内部其他位置出现的边界。本文通过为字符串$w[1..n]$的所有闭合子串引入仅需$\mathcal{O}(n \log n)$空间的紧凑表示,提出了计算所有$\mathcal{O}(n^2)$个闭合子串的快速$\mathcal{O}(n\log n)$时间算法。这些简洁且空间高效的算法还能计算最大闭合字符串。此外,我们比较了这些算法的性能,并识别出各类字符串中每种算法表现最优的情况。最后,我们证明对于$n \geq 5$的斐波那契词$f_n$,其最大闭合字符串的精确数量$M(f_n)$满足$\approx \left(1 + \frac{1}{φ^2}\right) F_n \approx 1.382 F_n$,其中$φ$为黄金分割比。