java - Why am I getting a different Huffman encoding tree from this reference tree? -
i have following values
event probability 0.3 b 0.3 c 0.13 d 0.12 e 0.1 f 0.05 my tree looks this
[1] /0 \1 [.4] [.6] 0/ \1 /0 \1 [.27][.13] [.3] [.3] 0/ \1 [.15] [.12] 0/ \1 [.1] [.05] i sorry bad representation thats best do.
i following example online values not same. unable understand doing wrong? if guide me in right direction.
example: http://www.math.upenn.edu/~deturck/m170/wk7/lecture/huffman/huffman.html
my values comes this:
a = 10 b = 11 but in example value = 00, , b = 01
i think 1 possible issue here in leftmost subtrees. correctly merged trees probabilities 0.05 , 0.10 form tree of net probability 0.15. however, @ point trees available have probabilities
0.3 0.3 b 0.15 ef 0.13 c 0.12 d the huffman encoding algorithm chooses 2 trees lowest total probabilities merge together, next step merge c , d. tree, seems instead merged ef , d, incorrect.
try merging using other approach , see if resolves things.
hope helps!
Comments
Post a Comment