文件名称:lzw
介绍说明--下载内容均来自于网络,请自行研究使用
实现lzw词典编码方法
Lzw编码算法的设计思路:
1.开始时的词典包含所有的根(先将所有单个字符编码),当前缀P时空的;
2.当前字符(C)=字符流中的下一个字符;
3.判断缀-符串P+C是否在词典中
A如果“是”:P=P+C//(用C扩展P)
B.如果“否”:
a 把代表当前前缀P的马子输出到码字流;
b 把缀-符串P+C添加到词典;
c 令P=C//(现在的P仅包含一个字符C);
4. 判断字符流中是否还有码字要译
(1)如果是,就返回到2;
(2)如果否
a 把代表当前前缀P的码字输出到码字流;
b 结束。.
-Coding method to achieve lzw dictionary coding algorithm Lzw design ideas: 1. The beginning of the dictionary contains all the root (first of all a single character encoding), the current time is made up of P 2. The current character (C) = the next character stream character 3. judge up- at string P+ C is in the dictionary, if A " is" : P = P+ C// (use C extension of P) B. If " no" : a prefix P to the representative of the current output of the commode to the code word stream b put up- at string P+ C added to the dictionary c so that P = C// (the P now contains only one character C) 4. to determine whether there are character stream code words to translate (1) If yes, on the return to the 2 (2) If it has a prefix P to the representative of the current output of the code word to code word stream b end. .
Lzw编码算法的设计思路:
1.开始时的词典包含所有的根(先将所有单个字符编码),当前缀P时空的;
2.当前字符(C)=字符流中的下一个字符;
3.判断缀-符串P+C是否在词典中
A如果“是”:P=P+C//(用C扩展P)
B.如果“否”:
a 把代表当前前缀P的马子输出到码字流;
b 把缀-符串P+C添加到词典;
c 令P=C//(现在的P仅包含一个字符C);
4. 判断字符流中是否还有码字要译
(1)如果是,就返回到2;
(2)如果否
a 把代表当前前缀P的码字输出到码字流;
b 结束。.
-Coding method to achieve lzw dictionary coding algorithm Lzw design ideas: 1. The beginning of the dictionary contains all the root (first of all a single character encoding), the current time is made up of P 2. The current character (C) = the next character stream character 3. judge up- at string P+ C is in the dictionary, if A " is" : P = P+ C// (use C extension of P) B. If " no" : a prefix P to the representative of the current output of the commode to the code word stream b put up- at string P+ C added to the dictionary c so that P = C// (the P now contains only one character C) 4. to determine whether there are character stream code words to translate (1) If yes, on the return to the 2 (2) If it has a prefix P to the representative of the current output of the code word to code word stream b end. .
(系统自动生成,下载前可以参看下载内容)
下载文件列表
lzw.cpp