English

RePair in Compressed Space and Time

Data Structures and Algorithms 2018-11-06 v1

Abstract

Given a string TT of length NN, the goal of grammar compression is to construct a small context-free grammar generating only TT. Among existing grammar compression methods, RePair (recursive paring) [Larsson and Moffat, 1999] is notable for achieving good compression ratios in practice. Although the original paper already achieved a time-optimal algorithm to compute the RePair grammar RePair(TT) in expected O(N)O(N) time, the study to reduce its working space is still active so that it is applicable to large-scale data. In this paper, we propose the first RePair algorithm working in compressed space, i.e., potentially o(N)o(N) space for highly compressible texts. The key idea is to give a new way to restructure an arbitrary grammar SS for TT into RePair(TT) in compressed space and time. Based on the recompression technique, we propose an algorithm for RePair(TT) in O(min(N,nmlogN))O(\min(N, nm \log N)) space and expected O(min(N,nmlogN)m)O(\min(N, nm \log N) m) time or O(min(N,nmlogN)loglogN)O(\min(N, nm \log N) \log \log N) time, where nn is the size of SS and mm is the number of variables in RePair(TT). We implemented our algorithm running in O(min(N,nmlogN)m)O(\min(N, nm \log N) m) time and show it can actually run in compressed space. We also present a new approach to reduce the peak memory usage of existing RePair algorithms combining with our algorithms, and show that the new approach outperforms, both in computation time and space, the most space efficient linear-time RePair implementation to date.

Keywords

Cite

@article{arxiv.1811.01472,
  title  = {RePair in Compressed Space and Time},
  author = {Kensuke Sakai and Tatsuya Ohno and Keisuke Goto and Yoshimasa Takabatake and Tomohiro I and Hiroshi Sakamoto},
  journal= {arXiv preprint arXiv:1811.01472},
  year   = {2018}
}
R2 v1 2026-06-23T05:03:45.182Z