I need a program that will enc/dec a an input file given a huffmann
coding. The program can be in c/c++ and will be required to have its
data from stdin.
Assume that I have an input file called "In" and a generated coding
scheme called "Code"
I should be able to do the follwing with these two SEPERATE modules:
cat In | ./encode Code > Out1
cat Out1 | ./decode Code > Out2
diff In Out2 //should be no different, should be the original file.
Sample Run:
//file that has some words that need to be encoded/decoded
[input]
i like computers
[/input]
//applying a freq. progarm to count chars/freq it will generate
[freq]
10 1
32 2
99 1
101 2
105 2
107 1
108 1
109 1
111 1
112 1
114 1
115 1
116 1
117 1
[/freq]
//applying the freq file to huffman program you will get the following
[code]
101 000
105 001
10 0100
99 0101
107 0110
108 0111
109 1000
111 1001
112 1010
114 1011
115 1100
116 1101
117 1110
32 1111
[/code]
//so from the code and input, we can encode/decode the files. These
are the TWO MODULES that need to be written
//encode program, if we apply "cat input | ./encode code > Out1"
//get a packed binary
[Out1]
|§á5£nÑ#
[/Out1]
//then I will call decode with "cat Out1 | ./decode.pl code >
original" and I should get the orignal input file which is
[original]
i like computers
[/original]
//by calling "diff original Out1 , it should return no differences
Both enc/dec must work in the follwing manner allowing redirecting/piping.
If you have any questions or would like something clarified, please
email me about it, because it needs to be in this specific format |