,
Panagiotis Charalampopoulos
,
Oded Lachish
,
Solon P. Pissis
,
Hilde Verbeek
Creative Commons Attribution 4.0 International license
We prove an elementary yet powerful combinatorial lemma: in any rooted tree with L leaves, the number of nodes whose depth is smaller than the number of their leaf descendants is at most L. For any string T of length n, a direct application of this lemma to the suffix trie of T yields that the number of substrings of T whose length is smaller than their number of occurrences in T is at most n. 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 n "frequent" substrings of T 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 𝒪(|P|+|Occ_T(P)|) to support counting queries in time 𝒪(|P|), where P is the queried pattern and Occ_T(P) is the set of occurrences of P in T. As applications, we show efficient indexes for consecutive occurrences, weighted sequences, strings with utilities, and non-overlapping occurrences.
@InProceedings{bals_et_al:LIPIcs.ESA.2026.68,
author = {Bals, Ben and Charalampopoulos, Panagiotis and Lachish, Oded and Pissis, Solon P. and Verbeek, Hilde},
title = {{Text Indexing: From Reporting to Counting}},
booktitle = {34th Annual European Symposium on Algorithms (ESA 2026)},
pages = {68:1--68:20},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-445-1},
ISSN = {1868-8969},
year = {2026},
volume = {388},
editor = {Bille, Philip and Pettie, Seth and Storandt, Sabine},
publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
address = {Dagstuhl, Germany},
URL = {https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ESA.2026.68},
URN = {urn:nbn:de:0030-drops-272046},
doi = {10.4230/LIPIcs.ESA.2026.68},
annote = {Keywords: text indexing, data structures, string algorithms, string processing}
}