English

Space-efficient SLP encoding for $O(\log N)$-time random access

Data Structures and Algorithms 2026-01-09 v3

Abstract

A Straight-Line Program (SLP) GG for a string TT is a context-free grammar (CFG) that derives TT only, which can be considered as a compressed representation of TT. In this paper, we show how to encode GG in nlgN+(n+n)lg(n+σ)+4n2n+o(n)n \lceil \lg N \rceil + (n + n') \lceil \lg (n+\sigma) \rceil + 4n - 2n' + o(n) bits to support random access queries of extracting T[p..q]T[p..q] in worst-case O(logN+qp)O(\log N + q - p) time, where NN is the length of TT, σ\sigma is the alphabet size, nn is the number of variables in GG and nnn' \le n is the number of symmetric centroid paths in the DAG representation for GG. The time complexity is almost optimal because Verbin and Yu [CPM 2013] proved that O(logN)O(\log N) term cannot be significantly improved in general with poly(n)\mathrm{poly}(n)-space data structures. We also present alternative encodings that achieve the same random access time with nlgN+nlg(n+σ)+5n+n+o(n)n \lceil \lg N \rceil + n \lceil \lg (n+\sigma) \rceil + 5n + n' + o(n) or nlgN+nlg(n+σ)+5nn+σ+o(n+σ)n \lceil \lg N \rceil + n \lceil \lg (n+\sigma) \rceil + 5n - n' + \sigma + o(n+\sigma) bits of space.

Keywords

Cite

@article{arxiv.2406.15011,
  title  = {Space-efficient SLP encoding for $O(\log N)$-time random access},
  author = {Akito Takasaka and Tomohiro I},
  journal= {arXiv preprint arXiv:2406.15011},
  year   = {2026}
}

Comments

An extended journal version accepted for publication in the Theory of Computing Systems

R2 v1 2026-06-28T17:14:32.190Z