• 第四次作业


    7、使用LZ77算法对一个序列进行编码。给定C(a)=1,C(p)=2,C(r)=3,C(t)=4。对已下三元组序列进行解码:

           <0,0,3> <0,0,1> <0,0,4> <2,8,2> <3,1,2> <0,0,3> <6,4,4> <9,5,4>

          假定窗口的大小为20,先行缓冲区的大小为10.对解码所得到的序列进行编码,确保得到相同的三元组序列。

           解:窗口大小为20,前向缓冲区大小为10,搜索窗口大小10。

                 C(a) = 1, C( ) = 2, C(r) = 3, C(t) = 4

    解码过程:   

          输入                                       输出:

           <0, 0, 3>                              r

          <0, 0, 1>                              ra

          <0, 0, 4>                              rat

          <2, 8, 2>                              ratatatatat

          <3, 1, 2>                              ratatatatat a

          <0, 0, 3>                              ratatatatat a r

          <6, 4, 4>                              ratatatatat a rat at

          <9, 5, 4>                              ratatatatat a rat at a rat

    编码过程:输入序列: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>

    编码输出的三元组与解码输入的三元组完全一样。

    8、给定以下初始词典和接收序列,构建一个LZW词典,并对所发送的序列进行解码。

             接收序列:4,5,3,1,2,8,2,7,9,7,4

             初始词典:

    索引

    1

     S

    2

    P

    3

    I

    4

    T

    5

    H

    接收到的序列:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:T

    1

    S

    2

    3

    I

    4

    T

    5

    H

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:TH

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:THI

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    7

    HI

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:THIS

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    7

    HI

    8

    IS

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:THIS

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    7

    HI

    8

    IS

    9

    S

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:THIS IS

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    7

    HI

    8

    IS

    9

    S

    10

     I

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:THIS IS

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    7

    HI

    8

    IS

    9

    S

    10

     I

    11

    IS

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                              解码出的序列:THIS IS HI

    1

    S

    2

    3

    I

    4

    T

    5

    H

    6

    TH

    7

    HI

    8

    IS

    9

    S

    10

     I

    11

    IS

    12

     H

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                             

    解码出的序列:THIS IS HIS

    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

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                             

    解码出的序列:THIS IS HIS HI

    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

    输入:4, 5, 3, 1, 2, 8, 2, 7, 9, 7, 4

    字典:                                             

    解码出的序列:THIS IS HIS HIT

    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

    15

    HIT

  • 相关阅读:
    新增桥接连接状态监控、重构日志系统
    v2.2发布,CNC Fanuc、QnA 1E驱动即将到来
    通过案例理解 MQTT 主题与通配符
    新增客户端和集群部署工具、HStream Cloud 开放体验申请
    提供流批结合计算能力
    Neuron v2.2.2 发布:MQTT插件功能提升 、新增OPC DA驱动
    v1.8.3 进行中:MQTT X CLI 支持多主题订阅,优化输出显示
    易操作、可观测、可扩展,EMQX如何简化物联网应用开发
    如何在Angular项目中使用MQTT
    vue3vmodel 父子组件数据双向同步
  • 原文地址:https://www.cnblogs.com/nieguilin/p/4849636.html
Copyright © 2020-2023  润新知