Click here to Skip to main content
15,917,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i want to code a program that, with huffman tree compress a file!
i am beginner in java , and have no idea how to start :|

do you have any idea or have any simple program like that ??

i founded many codes in other sites but all of them are too hard

and i cant understand those codes :(

please help
Posted

Have a look at Huffman.java[^]

It was the first search result I got from Google [^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Abhinav S 28-Dec-11 13:01pm    
My 5.
Espen Harlinn 28-Dec-11 13:19pm    
Thanks Abhinav :)
DominoBoy 28-Dec-11 13:09pm    
look at Dependencies: BinaryIn.java BinaryOut.java

i said i am beginner in java

thx anyway :)
Start writing a simple application for building the tree. The process is pretty strightforward, the initial tree (flat) should be ordered by symbol occurrences, then:
  1. Remove the the two bottom nodes from the tree, and create a new node having 'occurrences' equal to the sum of the occurrences of the removed ones (and having exactly the 'removed ones' as children).
  2. Insert the newly created node in the original tree (in the right position to maintain the tree ordered).


Repeat the two above steps until you have a properly single rooted tree.
If you have troubles in doing this, the you may post your doubts here.
 
Share this answer
 
v2
Comments
DominoBoy 28-Dec-11 13:13pm    
thx i try :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900