Talk:Huffman coding: Difference between revisions

static huff enc
(Huffman coding isn't for sets of symbols with the same frequency)
(static huff enc)
Line 32:
::: which obviously is an optimal code for this case. --[[User:Ce|Ce]] 14:17, 26 March 2009 (UTC)
::::Huffman coding in the case where all the symbols have the same frequency is not practical, though. If all the symbols have the same frequency no thought needs ot be put into it at all and you can just use ordinary binary encoding. --[[User:Mwn3d|Mwn3d]] 15:59, 26 March 2009 (UTC)
 
===By hand===
I made tons of that when coded my first Static Huffman cruncher eons ago (68k assembly, maybe I still can find the codes on old 3.5 floppies); by hand I made so
<pre>
A 50% ----------------\
B 25% ----------\ \
C 12.5% \ \ \ 100%
D 12.5% / 25% / 50% /
</pre>
 
so being "up" 1 and "down" 0: A=1, B=01, C=001, D=000. From here an algo can be extracted (by word in short: group 2-by-2 less frequent leaves; so first we have 12.5% and 12.5%, then we have the new leaf at 25%, and another one at 25%, so we join these... and so on). Dynamic Huffman Encoding is a little bit harder, not too much anyway, but I have never implemented that. I like this task, with a little bit of maquillage it's ok.
 
Now let's take the case all 25%
 
<pre>
A 25 \ 50 \
B 25 / \
C 25 \ / 100
D 25 / 50 /
</pre>
 
Id est, two bit for each letter. --[[User:ShinTakezou|ShinTakezou]] 16:33, 26 March 2009 (UTC)