tags:

views:

119

answers:

3

I have a project that should compress and decompress the text files in Java. I understand the Huffman algorithm, but I don't know how to code the whole project. Who can help me?

+2  A: 

Read the RFC.

awesomo
A: 

If that is homework and you are willing to forfeit your education and future by blindly copying what some random guy on the net told you, then you may want to have a look at jgz, an implementation in Java of the Deflate compression algorithm. Part of it uses Huffman codes. I wrote that code as a way to understand how Deflate works; since I left comments, that implementation may also help other people as well. Happy code reading.

Thomas Pornin
A: 

I would start with the classes that represent the tree (Node, Branch, Leaf).

Example

Then using those classes, create methods to map characters to bit sequences (and vice-versa.)

finnw