码迷,mamicode.com
首页 > 其他好文 > 详细

第四次作业

时间:2015-09-25 12:38:35      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

参考书《数据压缩导论(第4版)》  Page 121

7、使用LZ77算法对一个序列进行编码。给定C(a)=1,C(b)=2,C(r)=3,C(t)=4.对以下三元组序列进行解码:

                  <0,0,3><0,0,1><0,0,4><2,8,2><3,1,2><0,0,3><6,4,4><9,5,4>

假定窗口的大小为20,先行缓冲区的大小为10.对解码所得到的序列进行编码,确保得到相同的三元组序列。

解:解码过程:

         输入                                                         输出

      <0,0,3>                                                      r

      <0,0,1>                                                      ra

      <0,0,4>                                                      rat

      <2,8,2>                                                      ratatatatatb

      <3,1,2>                                                      ratatatatatbab

      <0,0,3>                                                      ratatatatatbabr

      <6,4,4>                                                      ratatatatatbabratbat

      <9,5,4>                                                      ratatatatatbabratbatbabrat

   编码过程:

      输入序列:ratatatatatbabratbatbabrat

       输入                                                           输出

    ||ratatatatatbabratbatbabrat                            <0,0,3> 

    |r|atatatatatbabratbatbabrat                            <0,0,1>

    |ra|tatatatatbabratbatbabrat                            <0,0,4>

    |rat|atatatatbabratbatbabrat                            <2,8,2>

    r|atatatatatb|abratbatbabrat                            <3,1,2>

    rat|atatatatbab|ratbatbabrat                            <0,0,3>

    ratat|atatatbabr|atbatbabrat                            <6,4,4>

    ratatatata|tbabratbat|babrat                            <9,5,4>

   编码输出的三元组与解码输入的三元组完全相同。

8、给定以下初始词典和接收序列,构建一个LZW词典,并对所发送的序列进行解码。

 接收序列:4,5,3,1,2,8,2,7,9,7,4

初始词典:

索引
1 S
2 b
3 I
4 T
5 H

解:

输入:4,5,3,1,2,8,2,7,9,7,4

字典:                                                                    解码得到的序列:T

S
2  
3 I
4 T
5 H

 

 

 

 

 

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:TH

字典: 

1 S
2  
3 I
4 T
5 H
6 TH

 

 

 

      

 

 

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:THI

字典:

1 S
2  
3 I
4 T
5 H
6 TH
7 HI

  

 

 

 

 

 

 

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:THIS

字典:

1 S
2  
3 I
4 T
5 H
6 TH
7 HI
8 IS

 

 

 

 

 

 

 

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:THIS

字典:

1 S
2  
3 I
4 T
5 H
6 TH
7 HI
8 IS
9 S

 

 

 

 

 

 

 

 输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:THIS IS

字典:

 

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:

字典:

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:

字典:

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:

字典:

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:

字典:

输入:4,5,3,1,2,8,2,7,9,7,4                                       解码得到的序列:

字典:

第四次作业

标签:

原文地址:http://www.cnblogs.com/zhangcui/p/4837489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!