lzw encoding

38
Robert Sedgewick and Kevin Wayne Copyright © 2005 http://www.Princeton.EDU/~cos226 LZW Encoding The input message was taken from: http://www-mtl.mit.edu/Courses/6.095/notes/LZW- examples.html

Upload: kamala

Post on 19-Mar-2016

43 views

Category:

Documents


0 download

DESCRIPTION

LZW Encoding. The input message was taken from: http://www-mtl.mit.edu/Courses/6.095/notes/LZW-examples.html. Input. Send. LZW Encoding. SEND. 256. i. 105. t. 116. Dictionary. t. 116. Index. Word. Index. Word. y. 121. 0. 258. it. _. 32. …. 259. tt. b. 98. i. 32. _. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: LZW Encoding

Robert Sedgewick and Kevin Wayne • Copyright © 2005 • http://www.Princeton.EDU/~cos226

LZW Encoding

The input message was taken from:http://www-mtl.mit.edu/Courses/6.095/notes/LZW-examples.html

Page 2: LZW Encoding

2

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

Page 3: LZW Encoding

3

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

Page 4: LZW Encoding

4

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

it

Page 5: LZW Encoding

5

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

tt

Page 6: LZW Encoding

6

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

ty

Page 7: LZW Encoding

7

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

y_

Page 8: LZW Encoding

8

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

_b

Page 9: LZW Encoding

9

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

bi

Page 10: LZW Encoding

10

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

itt

Page 11: LZW Encoding

11

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

ty_

Page 12: LZW Encoding

12

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

_bi

Page 13: LZW Encoding

13

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

it_

Page 14: LZW Encoding

14

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

_bin

Page 15: LZW Encoding

15

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

Page 16: LZW Encoding

16

LZW Encoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SEND

Page 17: LZW Encoding

17

105

Send

1161161213298

258

260

i

Input

tty_b

tty_

262bi

258t

i

_

266bi

110n257STOP

256SENDLZW Encoding

WordsOriginalMessage

18

Compression AchievedBits / word

8Total144

LZW message 14 9 126

Page 18: LZW Encoding

Robert Sedgewick and Kevin Wayne • Copyright © 2005 • http://www.Princeton.EDU/~cos226

LZW Decoding

Page 19: LZW Encoding

19

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 20: LZW Encoding

20

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 21: LZW Encoding

21

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 22: LZW Encoding

22

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 23: LZW Encoding

23

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 24: LZW Encoding

24

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 25: LZW Encoding

25

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 26: LZW Encoding

26

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 27: LZW Encoding

27

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 28: LZW Encoding

28

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 29: LZW Encoding

29

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 30: LZW Encoding

30

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 31: LZW Encoding

31

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 32: LZW Encoding

32

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 33: LZW Encoding

33

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 34: LZW Encoding

34

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 35: LZW Encoding

35

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 36: LZW Encoding

36

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 37: LZW Encoding

37

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND

Page 38: LZW Encoding

38

LZW Decoding

Word

_

ab

z

0Index

…32…9798

122

SEND…

256STOP257

itWord

tttyy__bbi

ty__biit_

_bin

258Index

259260261262263

265266267268

itt264

Dictionary105

Received

1161161213298

260

262

i

Input

tty_b

tty_

258bit

258 i

266 _bi

110 n257 STOP

256 SEND