paper

Text Indexing: From Reporting to Counting

arXiv:2607.24043

Abstract

We prove an elementary yet powerful combinatorial lemma: in any rooted tree with leaves, the number of nodes whose depth is smaller than the number of their leaf descendants is at most . For any string of length , a direct application of this lemma to the suffix trie of yields that the number of substrings of whose length is smaller than their number of occurrences in is at most . This combinatorial insight leads to space-efficient data structures with optimal query times for string counting problems via the following algorithmic framework: store the counts for the at most ``frequent'' substrings of in a preprocessing step, and use a reporting query to count for the ``infrequent'' substrings. Our framework acts as a convenient black box, lifting indexes with reporting time to support counting queries in time , where is the queried pattern and is the set of occurrences of in . As applications, we show efficient indexes for consecutive occurrences, weighted sequences, strings with utilities, and non-overlapping occurrences.

ESA 2026

Text Indexing: From Reporting to Counting · wovepaper