Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

huffman_encode_decode.py #3

Open
meiling-fdu opened this issue Sep 21, 2023 · 1 comment
Open

huffman_encode_decode.py #3

meiling-fdu opened this issue Sep 21, 2023 · 1 comment

Comments

@meiling-fdu
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant