in reply to Re: Re (tilly) 1: A Golf question maybe? Huffman with a twist
in thread A Golf question maybe? Huffman with a twist
The spec you give for a Huffman encoder means that you have to generate the tree by combining the lightest two subtrees at each step. Therefore your structure must evolve as follows (using parens and weights because my ascii art sucks):
That grouping is forced from your description of the Huffman spec, and conflicts with arranging the elements in order of ascending weight.(a:10 b:10 c:12 d:12 e:21 f:22) ((a b):20 c:12 d:12 e:21 f:22) ((a b):20 (c d):24 e:21 f:22) (((a b) e):41 (c d):24 f:22) (((a b) e):41 ((c d) f):46)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
A Brainteaser -- Huffman with a twist
by demerphq (Chancellor) on Sep 05, 2001 at 02:52 UTC | |
by tilly (Archbishop) on Sep 05, 2001 at 19:40 UTC |