Talk:Huffman coding: Difference between revisions

no edit summary
m (→‎By hand: what's wrong)
No edit summary
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)
:::::Huffman coding in the case where all the symbols have the same frequency will ''precisely'' generate the binary encoding. That's the whole point. Huffman coding always generates an optimal symbol-by-symbol coding.
:::::Anyway, a better example of Huffman coding I think would be something like the example at the top right of the Wikipedia article. The frequencies are taken from the string "this is an example of a huffman tree", and produces the following:
:::::{| class="wikitable"
!Char!!Freq!!Code
|-
|space||7/36||111
|-
|a ||4/36||010
|-
|e ||4/36||000
|-
|f ||3/36||1101
|-
|h ||2/36||1010
|-
|i ||2/36||1000
|-
|m ||2/36||0111
|-
|n ||2/36||0010
|-
|s ||2/36||1011
|-
|t ||2/36||0110
|-
|l ||1/36||11001
|-
|o ||1/36||00110
|-
|p ||1/36||10011
|-
|r ||1/36||11000
|-
|u ||1/36||00111
|-
|x ||1/36||10010
|}
:::::Your coding doesn't have to be exactly the same, but it should be equivalent to the above (i.e. codeword lengths should be the same, except that symbols with equal frequencies might be switched around). --[[Special:Contributions/76.167.241.45|76.167.241.45]] 18:55, 26 March 2009 (UTC)
 
===By hand===
Anonymous user