The coding of a user is dependent on the user tree.
The character string to be compressed uses the frequency of occurrence of each word as the basis to construct a user-defined tree. The more frequently the word is, the closer it is to the root node of the tree. Therefore, the shorter the encoding. Therefore, characters with high frequencies use short codes, and those with low frequencies use long codes. You can compress strings based on such a code table.
This program uses C.
Basically, it demonstrates the working principle of Harman encoding compression. Because it is a Demo code, you do not have to worry too much about efficiency. The program efficiency must be low.
According to the binary code consisting of a code table, the 7-bit ASCII code is converted into a group of ASCII code using 7-bit, 0-127), and there is a flag header to indicate whether there is excessive tail code. For more information, see code implementation.
This program can also be adapted to become a string encryption algorithm.
As follows:
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" inherit "border =" 0 "alt =" 967C955F6A784E96BB1EEF13EBEF0080 "height =" 211 "src =" http://www.bkjia.com/uploads/allimg/131228/1AI32164-0.jpg "/>
This article is from the "one blog" blog, please be sure to keep this source http://cnn237111.blog.51cto.com/2359144/1052372