Knowee
Questions
Features
Study Tools

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

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here are the steps to use Huffman algorithm to find the total size of the message "B C C A B B D D A E C C B B A E D D C C":

Step 1: Count the frequency of each character in the message.

A: 3 B: 5 C: 6 D: 4 E: 2

Step 2: Create a priority queue (min-heap) where the node with the lowest frequency has the highest priority.

Queue: [(A,3), (E,2), (D,4), (B,5), (C,6)]

Step 3: Create a Huffman Tree. Remove two nodes with the smallest frequency from the priority queue. Create a new node with these two nodes as children and with frequency equal to the sum of the two nodes' frequencies. Insert the new node into the queue.

First Iteration: Remove (A,3) and (E,2), create new node (AE,5) and insert into queue.

Queue: [(D,4), (B,5), (AE,5), (C,6)]

Second Iteration: Remove (D,4) and (B,5), create new node (DB,9) and insert into queue.

Queue: [(AE,5), (C,6), (DB,9)]

Third Iteration: Remove (AE,5) and (C,6), create new node (AEC,11) and insert into queue.

Queue: [(DB,9), (AEC,11)]

Fourth Iteration: Remove (DB,9) and (AEC,11), create new node (DBAEC,20) and insert into queue.

Queue: [(DBAEC,20)]

Step 4: Create a Huffman Code. Start from the root and assign codes to all edges such that the left edge gets 0 and the right edge gets 1. Traverse the tree to assign codes.

A: 100 B: 00 C: 101 D: 01 E: 110

Step 5: Calculate the total size of the message. Replace each character in the original message with its corresponding Huffman code and sum the length of all codes.

Total size = 33 + 52 + 63 + 42 + 2*3 = 9 + 10 + 18 + 8 + 6 = 51 bits

So, the total size of the message "B C C A B B D D A E C C B B A E D D C C" using Huffman algorithm is 51 bits.

This problem has been solved

Similar Questions

he 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 1 point43 bits45 bits40 bits41 bits

A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09 and 0.24, respectively. The optimal Huffman coding technique will have the average length of:a.2.15b.2.26c.2.40d.2.16

Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. What is the average length of Huffman codes?Group of answer choices2.18752.251.93753Next

Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a, b, c, d, e, f?Group of answer choices110, 100, 010, 000, 001, 11111, 10, 011, 010, 001, 00011, 10, 01, 001, 0001, 00000, 10, 110, 1110, 11110, 111

Discuss Huffman Algorithm in detail with suitable example.

1/3

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.