Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
i read file from input, then convert it to string and built the huffman tree
and gets the codes then, i write it to a file bit by bit, it works and decrease the size of file.
now i want to decompress that file , again i read that file bit by bit and save it to string, now i dont have any idea how to use codes to decompress :-??
please help


more information :
my prog have an array named
int[256] counts
that saves the freq of any object
also have an array named
String[256] codes
that saves the codes of any object

for example space(32):
index 32 of
int[256] counts
keep the freq of space
index 32 of
String[256] codes
keep the code of space

now think that the coded string is :
ASCII Code    Character       Frequency       Code

49                1             1             00
50                2             1             111
51                3             1             10
52                4             1             110
53                5             1             01

coded string is :
001111011001



how to decode ?
Posted

Hi Go Source- Bit by source- bit to your tree. When you reach a leafe then you have the next byte. And this until you reach the end of your compressed bit stream.

00 111 10 110 01
\ .etc
\
Data 49 -> "1"


Here you will find some more description.


http://www.cs.auckland.ac.nz/~jmor159/PLDS210/huffman.html[^]


You solved compressing by yourself so I see no problem that you can decompress it.
Regards
 
Share this answer
 
v3
Comments
DominoBoy 3-Jan-12 15:42pm    
thx i got it :)
[no name] 3-Jan-12 15:48pm    
Great! And once again, it is great that you try to do this stuff by yourself to study it. (sorry for my english...hope you can understand it :) )
Regards
bolivankit 3-Jan-12 22:48pm    
Awesome link :)
that may be good tutorial
Click Here
 
Share this answer
 

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