Question: The Java program Huffman.java should take as a command line argument the name of a file which contains some text. It should then compute the
The Java program Huffman.java should take as a command line argument the name of a file which contains some text. It should then compute the frequencies of the characters in that text and internally build the Huffman tree. You should then print out in the console window a table of characters along with the corresponding Huffman codes.
The program should then prompt the user to enter a code of 0's and ones. When you press enter the program should decode your input based on the Huffman tree that you constructed from the original input file. If there is an error in the code, print error, rather than the decoded message.
Finally, the program should prompt the user for a series of characters. When the user presses enter, those characters should be converted into the corresponding Huffman code based on the Huffman tree built from the original file input.
Use a Java HashMap to keep track of character frequencies
Create a HuffmanNode object to keep track of each key and its frequency
Use a priority queue
The last element will be the root node of the Huffman tree
Also include huffmantestfile.txt file separately to test the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
