Question: In class, we learned Huffman Code. It is used to encode a set of characters using binary code ( 0 and 1 ) to minimize
In class, we learned Huffman Code. It is used to encode a set of characters using binary code and to minimize the total length of codes. In this problem, let's practice to use Huffman Code.
pts Huffman Code is a type of prefix code. Can you briefly explain the concept, and what is the benefit of using prefix code?
pts Given a word forretress can you encode this word using Huffman Code? What is the total length of the code? Show your work.
pts Is your codeword the only valid Huffman code of the word? If not, please also give another valid encoding of word forretress, which is different from the one you showed in
Bonus pts As you can see, Huffman Code is not unique. In fact, Yan prefers more than He is wondering if you can design an algorithm that generates the Huffman Code and makes appears the most frequently in total. In this case, how many s and s do we have in the code for forretress? Note: the code should still be a Huffman code following the algorithm, instead of an arbitrary prefix code.
Bonus pts and candy Prove the optimality of your algorithm. Namely, it does generate the Huffman Code with the most possible s You can only get the bonus points and candy for this question when the algorithm in the previous question is correct.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
