Home > Back-end >  Huffman encoding/decoding
Huffman encoding/decoding

Time:10-07

[b] [problem description]
Using Huffman coding 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 decode (recovery) data and 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 code encoding/decoding system,
[basic requirements]
A complete system should have the following functions:
I: (1) the Initialization (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,
(2) E: coding (Encoding), the use of Huffman tree has been built (if not in memory, read from the file hfmTree), the file ToBeTran Encoding of the text, and then will result in the CodeFile file,
(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 50 code, at the same time the code written to the file of this character form CodePrin,
(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 TreePrint,
[test data]
(1) using the data in the textbook example 6-2 debugger,
(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,
Character A B C D E F G H I J K L M
Frequency, 186, 64, 13 22 32 103 21 15 47 57 1 5 20
Character N O P Q R S T U V W X Y Z
Frequency of 57 63 15 1 48 51, 80 23 August 18 16 1

[chosen for content]
(1) each of the above CodeFile file "0" or "1", in fact, take up the space of a byte, only have the effect of signal or simulation, to maximize the use of storage capacity, try to rewrite your system, the coding results in binary form in CodeFile file,
(2) to modify your system, the realization of the original program on your system of encoding and decoding (mainly the end-of-line character encoding/decoding problem),
(3) the source for the achievement of the transformation operations/mesh file, when choosing the operation specified by the user,

[/b]The great spirit of all stripes, please help!!!!!!!!!!!!!!!!!!!

CodePudding user response:

Must be written in c + +, please pay attention to a great god!

CodePudding user response:

The difficulty in where? You just don't want to write code?

CodePudding user response:

Hate homework, do yourself

CodePudding user response:

Quote: refer to the second floor lhylhy response:

A beginner, don't know much about these,

CodePudding user response:

Quote: refer to the third floor bigfog response:

Just learn this, the teacher suddenly to decorate, can't handle it,
  • Related