arXiv · 2602.10864
Random Access in Grammar-Compressed Strings: Optimal Trade-Offs in Almost All Parameter Regimes
Abstract
A Random Access query to a string $T\in [0..\sigma)^n$ asks for the character $T[i]$ at a given position $i\in [0..n)$. In $O(n\log\sigma)$ bits of space, this fundamental task admits constant-time queries. While this is optimal in the worst case, much research has focused on compressible strings, hoping for smaller data structures that still admit efficient queries. We investigate the grammar-compressed setting, where $T$ is represented by a straight-line grammar. Our main result is a general trade-off that optimizes Random Access time as a function of string length $n$, grammar size (the total length of productions) $g$, alphabet size $\sigma$, data structure size $M$, and word size $w=\Omega(\log n)$ of the word RAM model. For any $M$ with $g\log n 0$ [Belazzougui et al.; ESA'15], [Ganardi, Je\.z, Lohrey; J. ACM 2021]. The only tight lower bound [Verbin and Yu; CPM'13] was $\Omega(\frac{\log n}{\log\log n})$ for $w=\Theta(\log n)$, $n^{\Omega(1)}\le g\le n^{1-\Omega(1)}$, and $M=g\log^{\Theta(1)}n$. In contrast, our result yields tight bounds in all relevant parameters and almost all regimes. Our data structure admits efficient deterministic construction. It relies on novel grammar transformations that generalize contracting grammars [Ganardi; ESA'21]. Beyond Random Access, its variants support substring extraction, rank, and select.
Explore related subjects
Keep this discovery
Anouk Duyster, Tomasz Kociumaka. 2026-02-11. Random Access in Grammar-Compressed Strings: Optimal Trade-Offs in Almost All Parameter Regimes. https://arxiv.org/abs/2602.10864
Cite the original work for its findings. Save a collection to share your selection of sources.