Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Answer Calculate the frequencyweighted length for each symbol Multipl... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Algorithms questions