Question: Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The idea of Huffman coding is

Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. 

Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The idea of Huffman coding is quite simple: encode frequently used symbols with fewer bits. Huffman code is produced from the Huffman tree, which is a binary tree. Initially, we extract the frequency (occurrence count) of each symbol from the text file. In each step, we merge two sub-trees of the least frequency into a new binary tree, until the final binary tree is constructed. For each symbol, its Huffman code is the path from the root to the symbol node where we encode left-tree as '0' and right-tree as '1'. Here is an example of constructing Huffman tree: 15 15 15 13 Symbol A Frequency 15 Code 0 B 7 100 C 6 101 39 D 6 110 D E E 5 111 In this question, given the frequency of each symbol, can you calculate the total weighted length of the Huffman code of all symbols? For example the weighted length of the above Huffman tree is: 15X1+7X3+6X3+6X3+5X3=87 Well, the Huffman tree might not be unique when more than two symbols have the same frequency. However, the weighted length is always the same. In the example of four symbols with frequencies (3, 4, 7, 7), two possible Huffman trees could be constructed as follows:

Step by Step Solution

3.48 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer Calculate the frequencyweighted length for each symbol Multipl... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!