Reading:
Programming:
In order to gain access to files, this Java program will run as a stand-alone application rather than in applet. An example program including an application shell for an applet, file input output, and threading is given.
Modify this application to encode/decode using the Huffman algorithm given in Algorithms in C++. An encoded file has format the literal string HuffmanEncoded alone on the first line, followed by a representation on the Huffman tree on subsequent lines, followed by a newline, followed by the encoded data in 8-bit binary. If the program sees that the named file has first line matching this format, the program assumes it should decode the file. Else the program encodes the file, which can be assumed to be ASCII.
Hint
Do this program in the following phases:
A tree can be put into human/machine readable format using the formula:
+
/ \
ef +
/ \
a0 4f
If we assume that leaf contents will be hexidecimal, then
we can ignore any characters in the input besides:
Rather than go into it too much here, another html page has the details about this tree to string description conversion.