参考书《数据压缩导论(第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
所以编码序列为: ratatatatatbabratbatbabrat
解码:W=20,S=10
解:
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 |
_IS |
解码的序列为: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 |
_IS |
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 |
_IS |
11 |
IS_ |
12 |
_HI |
解码的序列为: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 |
_IS |
11 |
IS_ |
12 |
_HI |
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 |
_IS |
11 |
IS_ |
12 |
_HI |
13 |
HIS_ |
14 |
S_HI |
解码的序列为:THIS_IS_HIS_HIT