Fast Lempel-Ziv Decompression in Linear Space
We consider the problem of decompressing the Lempel-Ziv 77 representation of a string S∈[σ]^n using a working space as close as possible to the size z of the input. The folklore solution for the problem runs in optimal O(n) time but requires random access to the whole decompressed text. A better solution is to convert LZ77 into a grammar of size O(z(n/z)) and then stream S in optimal linear time. In this paper, we show that O(n) time and O(z) working space can be achieved for constant-size alphabets. On larger alphabets, we describe (i) a trade-off achieving O(n^δσ) time and O(z^1-δσ) space for any 0≤δ≤ 1, and (ii) a solution achieving optimal O(n) time and O(z n) space. Our solutions can, more generally, extract any specified subsequence of S with little overheads on top of the optimal running time and working space. As an immediate corollary, we show that our techniques yield improved results for pattern matching problems on LZ77-compressed text.
READ FULL TEXT