Question: File Compression using Huffman Coding The Problem You will be required to write a java application that uses Huffman compression to compress data in a

File Compression using Huffman Coding

The Problem

You will be required to write a java application that uses Huffman compression to compress data in a file named input.dat. For testing, you can use random text for the input.dat data, suggest using the first paragraph of the declaration of independence.

The main program module should be named Huffman.java

Load the file data in a persistent byte array named fileData, and will be a member of the Huffman class. This byte array will be used for building the frequency table, the Huffman tree, and outputting the bits.

The first step is to create a frequency table. The table will be an array of 256 integers and will be a member of the Huffman class. There must be a method named calculateFreqs to calculate a frequency table based on the loaded file data.

You must create class named BinaryMinHeap that acts as a Priority Queue. It should use generics for its type as discussed in class. You must support methods such as add and pop, and anything else necessary to operationsize being a good example.

You will need a data structure named HuffmanTreeNode. It is essentially a binary tree node. Use the class lecture to understand this and then to create the appropriate methods and fields.

Once the frequency table has been created, create a binary tree within a class named HuffmanTree. You will learn how to do this in class. An instantiation of theHuffmanTree class will be a member of the Huffman class.

With the binary tree created, create the compression table named compressionTable, as a member of the Huffman class. You will learn how to do this in class.

Finally, the output will go to the console. For each of the file bytes, output the uncompressed character following by the bit string that will be output.

The BinaryMinHeap class must support generics and implement Comparable.

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!