小编cli*_*ood的帖子

LZW减压算法

我正在为一个必须实现LZW压缩/解压缩的任务编写程序.我正在使用以下算法:

-压缩

w = NIL;
   while ( read a character k )
       {
         if wk exists in the dictionary
         w = wk;
         else
         add wk to the dictionary;
         output the code for w;
         w = k;
       }
Run Code Online (Sandbox Code Playgroud)

-减压

read a character k;
   output k;
   w = k;
   while ( read a character k )    
  /* k could be a character or a code. */
        {
         entry = dictionary entry for k;
         output entry;
         add w + entry[0] to dictionary;
         w …
Run Code Online (Sandbox Code Playgroud)

compression algorithm lzw

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

algorithm ×1

compression ×1

lzw ×1