English

Revisiting the Folklore Algorithm for Random Access to Grammar-Compressed Strings

Data Structures and Algorithms 2024-07-12 v1

Abstract

Grammar-based compression is a widely-accepted model of string compression that allows for efficient and direct manipulations on the compressed data. Most, if not all, such manipulations rely on the primitive \emph{random access} queries, a task of quickly returning the character at a specified position of the original uncompressed string without explicit decompression. While there are advanced data structures for random access to grammar-compressed strings that guarantee theoretical query time and space bounds, little has been done for the \emph{practical} perspective of this important problem. In this paper, we revisit a well-known folklore random access algorithm for grammars in the Chomsky normal form, modify it to work directly on general grammars, and show that this modified version is fast and memory efficient in practice.

Keywords

Cite

@article{arxiv.2407.08190,
  title  = {Revisiting the Folklore Algorithm for Random Access to Grammar-Compressed Strings},
  author = {Alan M. Cleary and Joseph Winjum and Jordan Dood and Shunsuke Inenaga},
  journal= {arXiv preprint arXiv:2407.08190},
  year   = {2024}
}
R2 v1 2026-06-28T17:36:44.766Z