Goal: Create a Huffman encoding simulation.

Description: Your program will generate the Huffman encoding for a given text file and output the character frequency and the encoded binary string. Additionally, output the size of the original text as well as the encoded string in bytes.

You will need a few different components to get this working: a priority queue, a frequency table, and the Huffman Tree itself.

  • Tips:
  • Design first. Then code.
  • Make sure each individual part works before putting them together. (Test your code!)
  • Feel free to rely on your text for help, but implement your own data structures
  • Helping each other is fine, but collaborate on ideas, not code
  • Consider a different type of node for the leaves

Huff Tree building in short:

  • Create n HuffTrees, each with a single letter
  • Enqueue all HuffTrees
  • Dequeue twice, combining and re-enqueuing the result
  • Repeat until the queue is empty

Input: A text file from the command line. (i.e. java jar MyHuff.jar MyTextFile.txt).

Output: The binary encoding of the input file. Print out the encoding in text format. Print out the frequency table for each character. Output the size of the original text and the potential size of the output binary string.

Deliverables: All source code (important), YourProgram.jar, readme.txt, Post-Mortem, Documentation

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.