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:54, 15 December 2006 (Note that the examples given are "upset down" for Canonical Huffman. Given example of code construction.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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 codes:
    print code
    code += 1
    if next bit length:
        code <<= 1

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