Home > database >  Data structure course design
Data structure course design

Time:12-12

1, Huffman encoding/decoding, using Huffman encoding information communication can greatly improve the channel utilization rate, shortening the time of information transmission, to reduce the transport cost, however, this requires the sender through a coding system to treat the data encoded in advance, will be on the receiving end of decoding (recovery). The data for duplex channel (namely can two-way transmission of information channel), each side needs a complete encoding/decoding system, test station for this information to write a Huffman encoding/decoding system,
[basic requirements] a complete system should have the following functions:
(1) 1: initialize (Initialization). Read from the terminal character set size n, and n characters and the weights of n, build the Huffman tree, and save it to the file hfmTree,
(Encoding). (2) E: coding using Huffman tree has been built (if not in memory, from a file htmT ree in reading), the file ToBeTran Encoding of the text, and then results in the file CodeFile I
(3) D: Decoding (Decoding). Using Huffman tree has been built in the CodeFile file code Decoding, result in the file TextFile,
(4) P: Print code file (Print) will CodeFile file on the terminal in a compact format, each row 5 0 code, at the same time the character code written in the form of file CodePrint,
(5) T: print Huffman Tree (Tree Printing) will have the Huffman Tree in memory in an intuitive manner (Tree or recessed table form) is shown in the terminal, at the same time the characters in the form of Huffman Tree written to the file TreePrin T,
[test data]
One (1) data: a system known in communication may occur only eight characters, its probability were 0.05, 0.29, 0.07, 0.08, 0.14, 0.23, 0.03, 0.11, with this design Huffman coding, using the data of program debugging,
(2) use the table below shows the character set and frequency of the actual statistical data to establish a Huffman tree, and the encoding and decoding to realize the following message: "THIS PROGRAM IS MY FAVORITE". 64 13 22 32, 103, 57, 63, 80
[implementation tips]
(1) CodeFile file base type can be set as the subrange type bit=0.. 10.
(2) the user interface can be designed as the "menu" way: according to the above function symbol, plus "Q", says running Q uit, when users type in a function, and then return to the menu functions has been completed,
  • Related