arXiv:2611.11552cs.DSNov 2026

Manuscript Offprint

arXiv:2611.11552

Internal Queries for Maximal Closed Substrings

Simone Faro, Francesco Pio Marino, Arianna Pavone

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Searching for repetitions inside a selected part of a text raises a subtle boundary problem: removing neighbouring characters can create new maximal answers. We study this effect for maximal closed substrings (MCSs). A string is closed if it is a single letter or has a nonempty proper prefix occurring exactly twice, as its prefix and suffix; a closed occurrence is maximal if neither available one-character extension is closed. Previous work established O(nlog⁡n)O(n\log n) bounds on the global MCS families of a length-nn text and developed enumeration algorithms. Internal queries instead ask for the MCSs of a chosen substring, with maximality evaluated inside that substring. Separating boundary occurrences from interior ones gives an O(nlog⁡n)O(n\log n)-word index that reports the cc answers in O(log⁡n+c)O(\log n+c) time and supports counting and longest queries in O(log⁡n)O(\log n) time. Our main result reduces reporting space to O(n)O(n) words, with O((c+1)log⁡1+εn)O((c+1)\log^{1+\varepsilon} n) query time and O(nlog⁡1+εn)O(n\log^{1+\varepsilon} n) construction time for any fixed ε>0\varepsilon>0. Thus, after preprocessing, reporting requires no additive scan of the queried substring, which is particularly useful for long queries with few answers. Independently, we prove that at most 3(s−1)3(s-1) MCS occurrences of any length-ss substring cross a fixed gap between consecutive characters, with maximality evaluated inside that substring. The same bound holds for global MCSs contained in a length-ss block. A family over two letters attains ⌊(s−1)/2⌋\lfloor(s-1)/2\rfloor crossings for every s≥3s\ge3, showing that the linear order of this local density bound is optimal.

A PDF page turning into lines of clean text

Preparing the full text

It will appear here by itself. You can read the abstract meanwhile.