Succinct data structure

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In computer science, a succinct data structure is a data structure which uses an amount of space that is "close" to the information-theoretic lower bound, but (unlike other compressed representations) still allows for efficient query operations. The concept was originally introduced by Jacobson [1] to encode bit vectors, (unlabeled) trees, and planar graphs. Unlike general lossless data compression algorithms, succinct data structures retain the ability to use them in-place, without decompressing them first. A related notion is that of a compressed data structure, in which the size of the data structure depends upon the particular data being represented.

Suppose that Z is the information-theoretical optimal number of bits needed to store some data. A representation of this data is called

  • implicit if it takes Z + O(1) bits of space,
  • succinct if it takes Z + o(Z) bits of space, and
  • compact if it takes O(Z) bits of space.

Implicit structures are thus usually reduced to storing information using some permutation of the input data; the most well-known example of this is the heap.

Succinct dictionaries[edit]

Succinct indexable dictionaries, also called rank/select dictionaries, form the basis of a number of succinct representation techniques, including binary trees, k-ary trees and multisets,[2] as well as suffix trees and arrays.[3] The basic problem is to store a subset S of a universe U =
[0 \dots n) = \{0, 1, \dots, n - 1\}, usually represented as a bit array B[0 \dots n) where B[i] = 1 iff i \in S. An indexable dictionary supports the usual methods on dictionaries (queries, and insertions/deletions in the dynamic case) as well as the following operations:

  • \mathbf{rank}_q(x) = |\{ k \in [0 \dots x] : B[k] = q \}|
  • \mathbf{select}_q(x)= \min \{k \in [0 \dots n) : \mathbf{rank}_q(k) = x\}

for q \in \{0, 1\}.

In other words, \mathbf{rank}_q(x) returns the number of elements equal to q up to position x while \mathbf{select}_q(x) returns the position of the  x-th occurrence of  q .

There is a simple representation [4] which uses n + o(n) bits of storage space (the original bit array and an o(n) auxiliary structure) and supports rank and select in constant time. It uses an idea similar to that for range-minimum queries; there are a constant number of recursions before stopping at a subproblem of a limited size. The bit array B is partitioned into large blocks of size l = \lg^2 n bits and small blocks of size s = \lg n / 2 bits. For each large block, the rank of its first bit is stored in a separate table R_l[0 \dots n/l); each such entry takes \lg n bits for a total of (n/l) \lg n = n / \lg n bits of storage. Within a large block, another directory R_s[0 \dots l/s) stores the rank of each of the l/s = 2 \lg n small blocks it contains. The difference here is that it only needs \lg l = \lg \lg^2 n = 2 \lg \lg n bits for each entry, since only the differences from the rank of the first bit in the containing large block need to be stored. Thus, this table takes a total of (n/s) \lg l = 4 n \lg \lg n / \lg n bits. A lookup table R_p can then be used that stores the answer to every possible rank query on a bit string of length s for i \in [0, s); this requires 2^s s \lg s = O(\sqrt{n} \lg n \lg \lg n) bits of storage space. Thus, since each of these auxiliary tables take o(n) space, this data structure supports rank queries in O(1) time and n + o(n) bits of space.

To answer a query for \mathbf{rank}_1(x) in constant time, a constant time algorithm computes

\mathbf{rank}_1(x) = R_l[\lfloor x / l \rfloor] + R_s[\lfloor x / s\rfloor] + R_p[x \lfloor x / s\rfloor, x \text{ mod } s]

In practice, the lookup table R_p can be replaced by bitwise operations and smaller tables to perform find the number of bits set in the small blocks. This is often beneficial, since succinct data structures find their uses in large data sets, in which case cache misses become much more frequent and the chances of the lookup table being evicted from closer CPU caches becomes higher.[5] Select queries can be easily supported by doing a binary search on the same auxiliary structure used for rank; however, this takes O(\lg n) time in the worst case. A more complicated structure using 3n/\lg \lg n + O(\sqrt{n} \lg n \lg \lg n) = o(n) bits of additional storage can be used to support select in constant time.[6] In practice, many of these solutions have hidden constants in the O(\cdot) notation which dominate before any asymptotic advantage becomes apparent; implementations using broadword operations and word-aligned blocks often perform better in practice.[7]

Entropy-compressed dictionaries[edit]

The n + o(n) space approach can be improved by noting that there are \textstyle \binom{n}{m} distinct m-subsets of [n) (or binary strings of length n with exactly m 1’s), and thus \textstyle \mathcal{B}(m,n) = \lceil \lg \binom{n}{m} \rceil is an information theoretic lower bound on the number of bits needed to store B. There is a succinct (static) dictionary which attains this bound, namely using \mathcal{B}(m,n) + o(\mathcal{B}(m,n)) space.[8] This structure can be extended to support rank and select queries and takes \mathcal{B}(m,n) + O(m + n \lg \lg n / \lg n) space.[2] This bound can be reduced to a space/time tradeoff by reducing the storage space of the dictionary to \mathcal{B}(m,n) + O(n t^t / \lg^t n + n^{3/4}) with queries taking O(t) time.[9]

Examples[edit]

When a sequence of variable-length items needs to be encoded, the items can simply be placed one after another, with no delimiters. A separate binary string consisting of 1s in the positions where an item begins, and 0s every where else is encoded along with it. Given this string, the select function can quickly determine where each item begins, given its index.[10]

Another example is the representation of a binary tree: an arbitrary binary tree on n nodes can be represented in 2n + o(n) bits while supporting a variety of operations on any node, which includes finding its parent, its left and right child, and returning the size of its subtree, each in constant time. The number of different binary trees on n nodes is {\tbinom{2n}{n}}/(n+1). For large n, this is about 4^n; thus we need at least about \log_2(4^n)=2n bits to encode it. A succinct binary tree therefore would occupy only 2 bits per node.

References[edit]

  1. ^ Jacobson, G. J (1988). Succinct static data structures. 
  2. ^ a b Raman, R.; V. Raman; S. S Rao (2002). "Succinct indexable dictionaries with applications to encoding k-ary trees and multisets". Proceedings of the thirteenth annual ACM-SIAM symposium on Discrete algorithms. pp. 233–242. ISBN 0-89871-513-X. 
  3. ^ Sadakane, K.; R. Grossi (2006). "Squeezing succinct data structures into entropy bounds". Proceedings of the seventeenth annual ACM-SIAM symposium on Discrete algorithm. pp. 1230–1239. ISBN 0-89871-605-5. 
  4. ^ Jacobson, G. (1989). Space-efficient static trees and graphs. 
  5. ^ González, R.; S. Grabowski; V. Mäkinen; G. Navarro (2005). "Practical implementation of rank and select queries". Poster Proceedings Volume of 4th Workshop on Efficient and Experimental Algorithms (WEA). pp. 27–38. 
  6. ^ Clark, D. (1998). Compact pat trees. 
  7. ^ Vigna, S. (2008). "Broadword implementation of rank/select queries". Experimental Algorithms. Lecture Notes in Computer Science 5038: 154–168. doi:10.1007/978-3-540-68552-4_12. ISBN 978-3-540-68548-7. 
  8. ^ Brodnik, A.; J. I Munro (1999). "Membership in constant time and almost-minimum space". SIAM J. Comput. 28 (5): 1627–1640. doi:10.1137/S0097539795294165. 
  9. ^ Pătraşcu, M. (2008). "Succincter". Foundations of Computer Science, 2008. FOCS'08. IEEE 49th Annual IEEE Symposium on. pp. 305–313. 
  10. ^ Belazzougui, Djamal. "Hash, displace, and compress".