Java Reference
In-Depth Information
(a)
(b)
F IGURE 25.25
(a) The animation shows the coding tree for a given text string and the
encoded bits for the text are displayed in the label; (b) You can enter a bit string to display
its text in the label.
***25.18
( Compress a file ) Write a program that compresses a source file into a target file
using the Huffman coding method. First use ObjectOutputStream to output
the Huffman codes into the target file, and then use BitOutputStream in
Programming Exercise 17.17 to output the encoded binary contents to the tar-
get file. Pass the files from the command line using the following command:
java Exercise25_18 sourcefile targetfile
***25.19
( Decompress a file ) The preceding exercise compresses a file. The compressed
file contains the Huffman codes and the compressed contents. Write a program
that decompresses a source file into a target file using the following command:
java Exercise25_19 sourcefile targetfile
25.20
( Bin packing using first fit ) Write a program that packs the objects of various
weights into containers. Each container can hold a maximum of 10 pounds. The
program uses a greedy algorithm that places an object into the first bin in which
it would fit. Your program should prompt the user to enter the total number of
 
 
Search WWH ::




Custom Search