I have a question about huffman coding. I know that in order to compress data using this method, we should order the probabilities from high to low. Then we add for example two of the lowest probabilities and we continue this until the final probability become 1. So that the ones which have higher probabilities will have shorter codes. My problem is that, imagine 3 of probabilities are the same, a=1/6 b=1/6 c=1/6 and we have put them in this order a, b, c . Is it possible the code which we give to b using huffman method, become shorter than the code we give to a ?
2026-04-07 01:54:58.1775526898
Length of codes in huffman method
56 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
Yes, this can happen. Imagine there are 17 equally-likely patterns; for us to assign them all equally-long codes, we would have to resort to 5-bit codes for each of them, and totally skip all of the shorter codes. We don't want to do something like that, so it's possible for equally-frequent patterns to have codes of unequal length.
As long as we have an accurate measure of the frequency of the patterns in the data, then what Huffman coding guarantees is that if pattern $A$ is more frequent than $B$, then the code for $A$ is no longer than that of $B$.