Jump to content

Talk:Canonical Huffman code

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sladen (talk | contribs) at 13:56, 15 December 2006 (slightly improve psuedo code). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This article probably needs the examples rewriting as Canonical Huffman coding starts with all-zeros for the shortest code and ends with all-ones for the longest code:

A   0
B  10
C 110
D 111

This is opposite to the examples as given. The method for construction is then:

code = 0
while more symbols:
    print symbol, code
    code = code + 1
    if next bit length:
        code = code << 1

Sladen 13:54, 15 December 2006 (UTC)[reply]