Question: 1. Huffman Coding Problem Statement The goal is to convert a character String into a binary string Huffman encoding. Some of the files have been

 1. Huffman Coding Problem Statement The goal is to convert a

1. Huffman Coding Problem Statement The goal is to convert a character String into a binary string Huffman encoding. Some of the files have been provided on Moodle, such as Huffman.java, Node.java and Tree.java. There are some gaps you will have to fill in. As we've seen, the way a Huffman tree is built is not deterministic, because when you have multiple trees with the same lowest weighting, you can choose any two of those to connect together, and you can put either one on the left or right. So let's make it deterministic by saying - where multiple trees have equal frequency, always connect the two trees containing the two lowest value ASCII characters, and always put the lowest of those two on the left. For instance, every ASCII character is associated with a number, so every tree will have a lowest value ASCII character in it-(e.g. capital A is the lowest ASCII letter). Always connect the two trees that have the lowest characters anywhere inside them, with the lowest on the left. Now everybody should end up with the same trees and the same coding. This as simple as saying: take the Priority Queue and as well as sorting on frequency, sort on lowest character as well. When two are popped from the Priority Queue, put the first to be popped on the left. Input Format A String like "hello" Output Format The Huffman encoding in binary like "1111100010" Sample Input hello Sample Output 1111100010 (try it on paper for yourself)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!