Balancing Two-Dimensional Straight-Line Programs

📅 2025-11-27
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This paper addresses the problem of efficient random access to a two-dimensional string (T) of size (N imes N), compressed via a two-dimensional straight-line program (2D SLP) of size (g). Unlike the well-established (O(g))-space, (O(log N))-time solution for one-dimensional SLPs, we first prove that no 2D SLP admits an (O(g))-space representation with (O(log N))-depth balanced structure. To overcome this, we introduce *hole-augmented 2D SLPs*, integrating 2D grammar compression, structured grammar transformation, and recursive tree depth-balancing. This yields a compact data structure using (O(g)) space and supporting random access in (O(log N)) time—further improved to (O(log N / log log N)). We also establish a tight lower bound of (Omega(g cdot N / log^3 N)), revealing the intrinsic hardness of 2D random access.

Technology Category

Application Category

📝 Abstract
We consider building, given a straight-line program (SLP) consisting of $g$ productions deriving a two-dimensional string $T$ of size $N imes N$, a structure capable of providing random access to any character of $T$. For one-dimensional strings, it is now known how to build a structure of size $mathcal{O}(g)$ that provides random access in $mathcal{O}(log N)$ time. In fact, it is known that this can be obtained by building an equivalent SLP of size $mathcal{O}(g)$ and depth $mathcal{O}(log N)$ [Ganardi, Jeż, Lohrey, JACM 2021]. We consider the analogous question for two-dimensional strings: can we build an equivalent SLP of roughly the same size and small depth? We show that the answer is negative: there exists an infinite family of two-dimensional strings of size $N imes N$ described by a 2D SLP of size $g$ such that any 2D SLP describing the same string of depth $mathcal{O}(log N)$ must be of size $Ω(gcdot N/log^{3}N)$. We complement this with an upper bound showing how to construct such a 2D SLP of size $mathcal{O}(gcdot N)$. Next, we observe that one can naturally define a generalization of 2D SLP, which we call 2D SLP with holes. We show that a known general balancing theorem by [Ganardi, Jeż, Lohrey, JACM 2021] immediately implies that, given a 2D SLP of size $g$ deriving a string of size $N imes N$, we can construct a 2D SLP with holes of depth $mathcal{O}(log N)$ and size $mathcal{O}(g)$. This allows us to conclude that there is a structure of size $mathcal{O}(g)$ providing random access in $mathcal{O}(log N)$ time for such a 2D SLP. Further, this can be extended (analogously as for a 1D SLP) to obtain a structure of size $mathcal{O}(g log^εN)$ providing random access in $mathcal{O}(log N/log log N)$ time, for any $ε>0$.
Problem

Research questions and friction points this paper is trying to address.

Investigates random access structures for 2D strings compressed by SLPs
Studies depth-size tradeoffs for balancing two-dimensional straight-line programs
Explores efficient query methods for compressed two-dimensional data
Innovation

Methods, ideas, or system contributions that make the work stand out.

Balancing 2D SLPs with holes for depth reduction
Constructing size O(g) structure for random access
Achieving O(log N) time random access in 2D
🔎 Similar Papers
No similar papers found.
Itai Boneh
Itai Boneh
Postdoc, Reichman University and University of Haifa
String AlgorithmsDynamic Algorithms
E
Estéban Gabory
Institute of Computer Science, University of Wrocław, Poland
P
Paweł Gawrychowski
Institute of Computer Science, University of Wrocław, Poland
A
Adam Górkiewicz
Institute of Computer Science, University of Wrocław, Poland