?? chapter6.htm
字號:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>笨笨數(shù)據(jù)壓縮教程</title>
</head>
<body bgcolor="#FFFFFF">
<p align="right"><a href="http://www.contextfree.net/">返回斷章取義堂</a> <a href="http://www.contextfree.net/wangyg/">返回詠剛的家</a></p>
<p style="background-color:#AAEEFF;font-size:14px;color:#0000AA">《笨笨數(shù)據(jù)壓縮教程》是我在1998年因工作需要研究壓縮算法時寫的文章(算是一種工作筆記吧,其中難免有許多疏漏),1999年初隨著項目變遷,就把壓縮技術(shù)的研究暫時擱置了。從那以后,一是工作太忙,二是自己懶惰,總之是沒能把半部壓縮教程補全。非常對不住大家。——王詠剛,2003年3月</p>
<p><img src="benben.jpg"
alt="笨笨數(shù)據(jù)壓縮教程(Benben's Data Compression Guide)"
width="370" height="129"></p>
<h2>第六章 聰明的以色列人(下):LZ78 和 LZW</h2>
<div align="right">
<address>
<a href="chapter5.htm">第五章</a> <a href="chapter7.htm">第七章</a>
</address>
</div>
<p>LZ78 的算法描述:</p>
<pre>for (;;)
{
current_match = 1;
current_length = 0;
memset(test_string, '\0', MAX_STRING);
for (;;)
{
test_string[current_length ++] = getc(input);
new_match = find_match(test_string);
if (new_match) == -1)
break;
current_match = new_match;
}
output_code(current_match);
output_char(test_string[current_letgth - 1];
add_string_to_dictionary(test_string);
}</pre>
<p>LZ78 示例:</p>
<pre>輸入正文: "DAD DADA DADDY DADO..."
輸出短語 輸出字符 編碼后的串
0 'D' "D"
0 'A' "A"
1 ' ' "D"
1 'A' "DA"
4 ' ' "DA "
4 'D' "DAD"
1 'Y' "DY"
0 ' ' " "
6 'O' "DADO"
此時字典的情況:
0 ""
1 "D"
2 "A"
3 "D "
4 "DA"
5 "DA "
6 "DAD"
7 "DY"
8 " "
9 "DADO"</pre>
<p> </p>
<div align="center"><center>
<address>
<a href="chapter5.htm">第五章</a> <a href="chapter7.htm">第七章</a>
</address>
</center></div><div align="right">
<address>
有問題嗎?有建議嗎?快給王笨笨寫信:wangyg@contextfree.net
</address>
</div><div align="right">
<address>
<strong>章節(jié)書簽:</strong><a href="default.htm">前言</a>
<a href="content.htm">目錄</a> <a href="chapter1.htm">1</a>
<a href="chapter2.htm">2</a> <a href="chapter3.htm">3</a> <a
href="chapter4.htm">4</a> <a href="chapter5.htm">5</a> <a
href="chapter6.htm">6</a> <a href="chapter7.htm">7</a> <a
href="chapter8.htm">8</a> <a href="chapter9.htm">9</a> <a
href="chapter10.htm">10</a> <a href="chapter11.htm">11</a> <a
href="chapter12.htm">12</a>
</address>
</div>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -