Fast and Compact Prefix Codes
Abstract
It is well-known that, given a probability distribution over n characters, in the worst case it takes ( (n n)) bits to store a prefix code with minimum expected codeword length. However, in this paper we first show that, for any 0<ε<1/2 with (1 / ε = n), it takes n (1 / ε) bits to store a prefix code with expected codeword length within ε of the minimum. We then show that, for any constant (c > 1), it takes n1 / c n bits to store a prefix code with expected codeword length at most c times the minimum. In both cases, our data structures allow us to encode and decode any character in 1 time.
0