Discussion:
Decode (Opt)
(too old to reply)
schoolie
2005-10-04 03:30:37 UTC
Permalink
what exactly should this do? I have most of the other code written but
I just don't get what to do for this or encode. A little help?
eruhk
2005-10-04 03:44:40 UTC
Permalink
opt adaptive encode: you're passed characters. if the character is in
the tree, output the code using writeCode (i think) and update the tree
accordingly. if it's not in the tree, output the code pointing to the
zero node. then output the character (using the 8 bits it would normally
take to represent it. so when you're decoding, if the 0-node is
indicated, you know that the next 8 bits are the new character.

rev adaptive encode: the tree is already formed. so all you have to do
is output the code to the indicated character then update the tree. for
decode, do the opposite.
Post by schoolie
what exactly should this do? I have most of the other code written but
I just don't get what to do for this or encode. A little help?
schoolie
2005-10-04 04:29:59 UTC
Permalink
Post by eruhk
opt adaptive encode: you're passed characters. if the character is in
the tree, output the code using writeCode (i think) and update the tree
accordingly. if it's not in the tree, output the code pointing to the
zero node. then output the character (using the 8 bits it would normally
take to represent it. so when you're decoding, if the 0-node is
indicated, you know that the next 8 bits are the new character.
rev adaptive encode: the tree is already formed. so all you have to do
is output the code to the indicated character then update the tree. for
decode, do the opposite.
Post by schoolie
what exactly should this do? I have most of the other code written but
I just don't get what to do for this or encode. A little help?
Thanks alot. That all makes sense now. The only thing I don't
understand is the ZeroNode. I can't see how it is kept track of or how
to find where it is. I am totally missing the concept. I don't
understand what the line in the replaceZero function: place(2, new
WeightedNode((byte)0, 0)); or why it always returns 2. I see in the
psuedo code that ai(i+1) (er something) should be the right child result
of adding the two leaf 0 node children but it just doesn't make
sense.... I'm totally missing something.

Loading...