Abstract

Given a string SS of length NN on a fixed alphabet of σσ symbols, a grammar compressor produces a context-free grammar GG of size nn that generates SS and only SS. In this paper we describe data structures to support the following operations on a grammar-compressed string: $\mbox{rank}_c(S,i)$ (return the number of occurrences of symbol cc before position ii in SS); $\mbox{select}_c(S,i)$ (return the position of the iith occurrence of cc in SS); and $\mbox{access}(S,i,j)$ (return substring S[i,j]S[i,j]). For rank and select we describe data structures of size O(nσlog⁡N)O(nσ\log N) bits that support the two operations in O(log⁡N)O(\log N) time. We propose another structure that uses O(nσlog⁡(N/n)(log⁡N)1+ε)O(nσ\log (N/n)(\log N)^{1+ε}) bits and that supports the two queries in O(log⁡N/log⁡log⁡N)O(\log N/\log\log N), where ε>0ε>0 is an arbitrary constant. To our knowledge, we are the first to study the asymptotic complexity of rank and select in the grammar-compressed setting, and we provide a hardness result showing that significantly improving the bounds we achieve would imply a major breakthrough on a hard graph-theoretical problem. Our main result for access is a method that requires O(nlog⁡N)O(n\log N) bits of space and O(log⁡N+m/log⁡σN)O(\log N+m/\log_σN) time to extract m=j−i+1m=j-i+1 consecutive symbols from SS. Alternatively, we can achieve O(log⁡N/log⁡log⁡N+m/log⁡σN)O(\log N/\log\log N+m/\log_σN) query time using O(nlog⁡(N/n)(log⁡N)1+ε)O(n\log (N/n)(\log N)^{1+ε}) bits of space. This matches a lower bound stated by Verbin and Yu for strings where NN is polynomially related to nn.

Explore this paper’s authors, topics and related work.

Building this map preview

BZPEER is loading the nearby papers, people, topics and institutions for this page.

Reviews 0

Write a reviewWrite

No reviews yet.

Discussion 0

Add a commentWrite

No comments yet.