Huffman codes: The following table gives the frequencies of each character in a
ID: 648567 • Letter: H
Question
Huffman codes: The following table gives the frequencies of each character in a file with 1 000 characters.
1. How many bits do we need to store the file if using a fixed-length code? Show the code built by the Huffman algorithm, both as a tree and as a list (character, codeword). How many bits do we need to store the file with this Huffman code?
2. And Assume now that all the characters have the same frequency (= 125). Show the code built by the Huffman algorithm, both as a tree and as a list (character, codeword). How many bits do we need to store the file with this Huffman code? Generalizing from this example, what can you say about the code built by the Huffman algorithm for an alphabet with n = 2b characters each of which occurs with equal frequency f?
Explain your answer.
Explanation / Answer
1 . Since we are using fixed length encoding and there are 8 characters
so we will need 3 bits to represent any character
000
001
010
011
100
101
110
111
Since there are in total 1000 characteres so
bits required = 1000*3 = 3000
2.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.