Random Access to Grammar Compressed Strings
Abstract
Grammar based compression, where one replaces a long string by a small context-free grammar that generates the string, is a simple and powerful paradigm that captures many popular compression schemes. In this paper, we present a novel grammar representation that allows efficient random access to any character or substring without decompressing the string. Let be a string of length compressed into a context-free grammar of size . We present two representations of achieving random access time, and either construction time and space on the pointer machine model, or construction time and space on the RAM. Here, is the inverse of the row of Ackermann's function. Our representations also efficiently support decompression of any substring in : we can decompress any substring of length in the same complexity as a single random access query and additional time. Combining these results with fast algorithms for uncompressed approximate string matching leads to several efficient algorithms for approximate string matching on grammar-compressed strings without decompression. For instance, we can find all approximate occurrences of a pattern with at most errors in time , where is the number of occurrences of in . Finally, we generalize our results to navigation and other operations on grammar-compressed ordered trees. All of the above bounds significantly improve the currently best known results. To achieve these bounds, we introduce several new techniques and data structures of independent interest, including a predecessor data structure, two "biased" weighted ancestor data structures, and a compact representation of heavy paths in grammars.
Cite
@article{arxiv.1001.1565,
title = {Random Access to Grammar Compressed Strings},
author = {Philip Bille and Gad M. Landau and Rajeev Raman and Kunihiko Sadakane and Srinivasa Rao Satti and Oren Weimann},
journal= {arXiv preprint arXiv:1001.1565},
year = {2013}
}
Comments
Preliminary version in SODA 2011