一、 参考书《数据压缩导论(第4版)》 Page 121
7,8
解:
C(a)=1,C(b)=2,C(r)=3,C(t)=4;
解码过程:
序列 |
输出 |
<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
|
编码过程:输入序列:ratatatatat a rat at a rat
接下来继续编码:
输入 | 输出 |
||ratatatatat a rat at a rat | <0, 0, 3> |
|r|atatatatat a rat at a rat | <0, 0, 1> |
|ra|tatatatat a rat at a rat | <0, 0, 4> |
|rat|atatatat a rat at a rat | <2, 8, 2> |
ra|tatatatat |a rat at a rat | <3, 1, 2> |
rata|tatatat a |rat at a rat | <0, 0, 3> |
ratat|atatat a r|at at a rat | <6, 4, 4> |
ratatatata|t a rat at| a rat | <9, 5, 4> |
根据这2个过程得出:编码输出的三元组与解码输入的三元组完全一样。
8.给定一下初始词典和接收序列,构建一个LZW词典,并对所发送的序列进行编码。
接收序列:4,5,3,1,2,8,2,7,9,7,4
初始字典:
索引 | 项 |
1 | S |
2 | |
3 | I |
4 | T |
5 | H |
解:
(1)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _(空格) |
3 | I |
4 | T |
5 | H |
该数解码的序列为:T
(2)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | (空格) |
3 | I |
4 | T |
5 | H |
该数解码的序列为:TH
(3)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _(空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
该数解码的序列为:THI
(4)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
该数解码的序列为:THIS
(5)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
该数解码的序列为:THIS_
(6)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
9 | S_ |
该数解码的序列为:THIS IS
(7)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
9 | S_ |
10 | _I |
该数解码的序列为:THIS IS_
(8)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
9 | S_ |
10 | _I |
11 | IS_ |
该数解码的序列为:THIS IS HI
(9)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
9 | S_ |
10 | _I |
11 | IS_ |
12 | _H |
该数解码的序列为:THIS IS HIS_
(10)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
9 | S_ |
10 | _I |
11 | IS_ |
12 | _H |
13 | HIS |
该数解码的序列为:THIS IS HIS HI
(11)输入4,5,3,1,2,8,2,7,9,7,4
索引 | 条目 |
1 | S |
2 | _ (空格) |
3 | I |
4 | T |
5 | H |
6 | TH |
7 | HI |
8 | IS |
9 | S_ |
10 | _I |
11 | IS_ |
12 | _H |
13 | HIS |
14 | S_H |
该数解码的序列为:THIS IS HIS HIT