Ritwik00025 / Data-Compression

The implementation of various data compression techniques.
40 stars 11 forks source link

huffman_encode_decode.py #3

Open meiling-fdu opened 11 months ago

meiling-fdu commented 11 months ago

There exists some error in the code. For example, for probability list [0.15850000083446503, 0.15620000660419464, 0.15389999747276306, 0.12359999865293503, 0.11129999905824661, 0.10100000351667404, 0.0982000008225441, 0.09719999879598618], the program generates:

Alphabet Codeword 0.09719999879598618 0101110 0.0982000008225441 0101111 0.10100000351667404 011110 0.11129999905824661 011111 0.12359999865293503 10110 0.15389999747276306 10111 0.15620000660419464 1110 0.15850000083446503 1111

while actually, the constructed huffman tree is a full binary tree, and the above codeword should be: 000,001,010,011,100,101,110,111

meiling-fdu commented 11 months ago

The huffman tree won't have any node whose degree is 1.