The following Message "B C C A B B D D A E C C B B A E D D C C", is given. Use Huffman algorithm to find the total size of the message
Question
The following Message
B C C A B B D D A E C C B B A E D D C C
, is given. Use Huffman algorithm to find the total size of the message.
Solution
Sure, let's use Huffman's algorithm to find the total size of the message. Here are the steps:
-
First, we need to calculate the frequency of each character in the message:
A: 3 B: 4 C: 6 D: 4 E: 2
-
Now, we create a priority queue (min-heap) where the node with the lowest frequency has the highest priority:
E: 2 A: 3 B: 4 D: 4 C: 6
-
We remove two nodes with the highest priority (lowest frequency) from the queue and create a new node with these two nodes as children. The new node's frequency is the sum of the two nodes' frequencies. We insert the new node back into the queue. We repeat this step until there is only one node left in the queue.
AE: 5 B: 4 D: 4 C: 6
BAE: 9 D: 4 C: 6
DBAE: 13 C: 6
CDBAE: 19
-
The final Huffman tree is CDBAE. Now, we assign binary codes to each character according to their position in the Huffman tree. Characters in the left subtree get a '0' and characters in the right subtree get a '1'.
A: 100 B: 101 C: 0 D: 110 E: 111
-
Now, we replace each character in the original message with its corresponding binary code:
B C C A B B D D A E C C B B A E D D C C becomes 101 0 0 100 101 101 110 110 100 111 0 0 101 101 100 111 110 110 0 0
-
Finally, we calculate the total size of the message by counting the number of bits in the encoded message. Each character is now represented by 3 bits, so the total size of the message is 3 bits * 20 characters = 60 bits.
So, the total size of the message using Huffman's algorithm is 60 bits.
Similar Questions
Use Huffman method to obtain the optimum code for the following dataABCDEF0.150.40.050.20.050.15
Apply Huffman - Coding procedure for M-2.And find the coding efficiency.Given: [X]= [xl x2 x3 x4 x5 x6 x7 x8][P}-[0.1,0.25,0.15,0.05,0.15,0.1,0.05,0.15]
What is the average number of bits for each letter of the word "amazing" using Huffman coding algorithm? Select one:a.18/7b.19/7c.3d.20/7e.None of thesef.17/7
huffmann codes areSelect one:a. uniquely decodableb. lossless source coding techniquec. all of themd. variable length codes
24. The person who receives the message is called _________. A. sender B. receiver C. encoding D. decoding
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.