Feng Juan's fourth time assignment

Source: Internet
Author: User

Reference exercises:

7. Encode a sequence using the LZ77 algorithm. Given C (a) =1,c (b) =2,c (R) =3,c (t) = 5, the ternary sequence is decoded:

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

Assume that the size of the window is 20, the size of the antecedent buffer is 10. Encode the sequence obtained by decoding to ensure that the same ternary sequence is obtained.

Solution:

Sequence

Output

<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

Encoding process:

Input sequence: Rat Atatatatbabratbatbabrat

Input

Output

R _atatatatatbabratbatbabrat

<0,0,3>

Ra_ Tatatatatbabratbatbabrat

<0,0,1>

Rat _ Atatatatbabratbatbabrat

<0,0,4>

R _atatatatatb_ Abratbatbabrat

<2,8,2>

Rat_ Atatatatba _ Bratbatbabrat

<3,1,2>

Rata _ tatatatbab _ Ratbatbabrat

<0,0,3>

Ratatatatatbabratbatbabrat

<6,4,4,>

Ratatatatatbabratbatbabrat

<9,5,4>

8. Given the following initial dictionaries and acceptance sequences, construct an LZW dictionary and decode the multiple sent sequences. Acceptance sequence: 4,5,3,1,2,8,2,7,9,7,4

Initial dictionary:

Index Item
1 S
2 P
3 I
4 T
5 H

Solution:

1) Input 4,5,3,1,2,8,2,7,9,7,4

Index Entry
1 S
2 _
3 I
4 T
5 H

The decoded sequence is: T

2) Input 4,5,3,1,2,8,2,7,9,7,4

Index Entry
1 S
2 -
3 I
4 T
5 H

The decoded sequence is: TH

3) Input 4,5,3,1,2,8,2,7,9,7,4

Index Entry
1 S
2 _
3 I
4 T
5 H
6 TH

The decoded sequence is: THI

10) Input 4,5,3,1,2,8,2,7,9,7,4

Index Entry
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

The decoded sequence is: The is the his HI

11) Input 4,5,3,1,2,8,2,7,9,7,4

Index Entry
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 R_i

The decoded sequence is:

The last decoding sequence is:

Feng Juan's fourth time assignment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.