📄 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>笨笨数据压缩教程</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">《笨笨数据压缩教程》是我在1998年因工作需要研究压缩算法时写的文章(算是一种工作笔记吧,其中难免有许多疏漏),1999年初随着项目变迁,就把压缩技术的研究暂时搁置了。从那以后,一是工作太忙,二是自己懒惰,总之是没能把半部压缩教程补全。非常对不住大家。——王咏刚,2003年3月</p>
<p><img src="benben.jpg"
alt="笨笨数据压缩教程(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>章节书签:</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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -