第六章 聪明的以色列人(下):LZ78 和 LZW

LZ78 的算法描述:

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);
}

LZ78 示例:

输入正文: "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"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值