Skip to content

Space-Efficient Text Indexing for Advanced Counting Queries

Solon P. Pissis, Sharma V. Thankachan

cs.DSarXiv:2611.27432

Abstract

In the classical problem of text indexing, the objective is to preprocess a text T=T[1..n] over an integer alphabet [0..σ) into a data structure that supports efficient pattern matching queries. Given a pattern P=P[1..m], a reporting query lists the set OccT(P) of occurrences of P in T, whereas a counting query returns |OccT(P)|. Space-efficient suffix-tree variants use only O(nσ) bits and support reporting queries in O(m+|OccT(P)|·σε n) time, where ε>0 is an arbitrarily small constant, and counting queries in O(m) time. Notably, space-efficient indexes for more advanced counting queries have largely resisted achieving the same optimal (or near-optimal) query times when using less than Θ(n n) bits. We change this situation by proposing a general framework that supports advanced counting queries, denoted by ϕT(P), provided that ϕT satisfies two mild conditions: (1) ϕT(P) is an integer in [0..|OccT(P)|] that can be computed from OccT(P) via sorting; and (2) ϕT(Q)≥ϕT(P) for every prefix Q of P. We show that our framework supports optimal O(m)-time queries using O(nσ+n( n)2) bits or near-optimal O(mσε n)-time queries using O(nσ) bits. As an example, our trade-offs improve upon the classical MAST index for counting non-overlapping occurrences [Apostolico and Preparata, Algorithmica, 1996; Brodal et al., ICALP 2002], which uses O(n n) bits and supports O(m)-time queries, and the recent compact index for the same problem [Bals et al., ESA 2026], which uses O(nσ) bits and supports O(m nσε n)-time queries.

Create a lesson