English

Faster and Simpler Online Computation of String Net Frequency

Data Structures and Algorithms 2026-01-01 v3

Abstract

An occurrence of a repeated substring uu in a string SS is called a net occurrence if extending the occurrence to the left or to the right decreases the number of occurrences to 1. The net frequency (NF) of a repeated substring uu in a string SS is the number of net occurrences of uu in SS. Very recently, Guo et al. [SPIRE 2024] proposed an online O(nlogσ)O(n \log \sigma)-time algorithm that maintains a data structure of O(n)O(n) space which answers Single-NF queries in O(mlogσ+σ2)O(m\log \sigma + \sigma^2) time and reports all answers of the All-NF problem in O(nσ2)O(n\sigma^2) time. Here, nn is the length of the input string SS, mm is the query pattern length, and σ\sigma is the alphabet size. The σ2\sigma^2 term is a major drawback of their method since computing string net frequencies is originally motivated for Chinese language processing where σ\sigma can be thousands large. This paper presents an improved online O(nlogσ)O(n \log \sigma)-time algorithm, which answers Single-NF queries in O(mlogσ)O(m \log \sigma) time and reports all answers to the All-NF problem in output-optimal O(NF+(S))O(|\mathsf{NF}^+(S)|) time, where NF+(S)\mathsf{NF}^+(S) is the set of substrings of SS paired with their positive NF values. We note that NF+(S)=O(n)|\mathsf{NF}^+(S)| = O(n) always holds. In contract to Guo et al.'s algorithm that is based on Ukkonen's suffix tree construction, our algorithm is based on Weiner's suffix tree construction.

Keywords

Cite

@article{arxiv.2410.06837,
  title  = {Faster and Simpler Online Computation of String Net Frequency},
  author = {Shunsuke Inenaga},
  journal= {arXiv preprint arXiv:2410.06837},
  year   = {2026}
}
R2 v1 2026-06-28T19:14:19.434Z