I'm solving an exercise in a book about compression, it says if we have the alphabet[A,B,C] and probablities P(A)=0.5,P(B)=0.4,P(C)=0.1 how many bits needed for encoding BBB with huffman and arithmetic.
Now the book itself says in a section "BBB requires 6 bits with huffman but only 4 bits with arithmetic", I have verified that arithmetic needs 4 bits but don't know why huffman needs 6.
I solved huffman like this :
B(3)
P1(3)
EOF(0) B(3)
so B is encoded with one bit only !!
I thought maybe I should include the whole alphabet like this :
A(0),C(0),B(3)
P1(0) B(3)
A(0) C(0)
P2(3)
P1(0) B(3)
A(0) C(0)
still B needs 1 bit(but A and C 2 bits, still no 6 !!).
What am I doing wrong here ?