Randomized trial finds faster solutions for unique and absent substrings, suggesting improved efficiency for string analysis.
We revisit two well-known algorithmic problems on strings: computing a shortest unique substring (SUS) and a shortest absent substring (SAS) in a string S of length n. Both problems admit folklore πͺ(n)-time solutions using the suffix tree of S. However, for small alphabets, this complexity is not necessarily optimal in the word RAM model, where a string of length n over alphabet [0,Ο) can be stored in πͺ(n log Ο/log n) space and read in πͺ(n log Ο/log n) time. We present an πͺ(n log Ο/β{log n})-time algorithm for computing a SUS in S. This algorithm decomposes the problem according to the length and the period of the sought substring and uses several tools and techniques, such as synchronizing sets, the analysis of runs, and wavelet trees, to reduce the computation of a SUS to a simple geometric problem. Further, we adapt this algorithm and combine it with an efficient construction of de Bruijn sequences in order to obtain an πͺ(n log Ο/β{log n})-time algorithm for computing a SAS in S.
No takes yet. Share an insight, caveat, or question.
Charalampopoulos et al. (2026) studied this question.