A
A
agorkov2012-02-18 18:47:02
Algorithms
agorkov, 2012-02-18 18:47:02

Efficient transmission of Huffman codes?

My scientific work is related to data compression and now I am trying to solve one very specific problem.
There is an input alphabet of N m-bit numbers (N>=10^6; m=24). For each of the N symbols, the frequency of its occurrence is known. Based on this information, Huffman codes are obtained for all symbols.
The task is to create a transmission from which it is possible to uniquely recover both the m-bit numbers themselves and their Huffman codes. Of course, the transfer should be as small as possible.
The option that I myself thought of requires N * (m + 2) -1 bits. If someone manages to improve my result, please share your solution.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mrrl, 2012-02-18
@Mrl

Something is wrong in the condition. There are only 16*10^6 24-bit numbers, there is no way to get 2^9 of them.
And the question is - do you need to get exactly the given Huffman codes, or is it enough to get some equivalent in length (and the packing and unpacking algorithms themselves agree that the unpacked codes are exactly those that are used when packing the main message)?

M
Mrrl, 2012-02-19
@Mrl

If you need to transmit a truly arbitrary Huffman code, then there is almost nothing to win. The code is determined by an N-element vector of m-bit numbers (with the condition that all elements are different) - these are letters sorted by codes, and the placement of brackets in an expression of N operands - this is a binary tree. The number of vectors is (2^m)!/(2^mN)!, the number of trees is C(N,2*N)/(4*N-2). If N is noticeably less than 2^m, then the first of these numbers can be estimated as 2^(m*N), and the second as 2^(2*N)/(4*N-2)/sqrt(pi* N). The total number of bits in their product is approximately m*N+2*N.
As N approaches 2^m, it becomes possible to win up to 1.4*N bits (due to the fact that (2^m)!< (2^m)^(2^m).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question