Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Demo lzw

737 views

Published on

  • Be the first to comment

Demo lzw

  1. 1. Princeton University • COS 226 • Algorithms and Data Structures • Spring 2004 • Kevin Wayne • 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
  2. 2. 2 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND
  3. 3. 3 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND
  4. 4. 4 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND it
  5. 5. 5 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND tt
  6. 6. 6 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND ty
  7. 7. 7 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND y_
  8. 8. 8 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND _b
  9. 9. 9 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND bi
  10. 10. 10 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND itt
  11. 11. 11 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND ty_
  12. 12. 12 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND _bi
  13. 13. 13 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND it_
  14. 14. 14 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND _bin
  15. 15. 15 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND
  16. 16. 16 LZW Encoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND
  17. 17. 17 105 Send 116 116 121 32 98 258 260 i Input t t y _ b t t y _ 262b i 258t i _ 266 b i 110n 257STOP 256SEND LZW Encoding Words Original Message 18 Compression Achieved Bits / word 8 Total 144 LZW message 14 9 126
  18. 18. Princeton University • COS 226 • Algorithms and Data Structures • Spring 2004 • Kevin Wayne • http://www.Princeton.EDU/~cos226 LZW Decoding The input message was taken from: • http://www-mtl.mit.edu/Courses/6.095/notes/LZW-examples.html
  19. 19. 19 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  20. 20. 20 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  21. 21. 21 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  22. 22. 22 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  23. 23. 23 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  24. 24. 24 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  25. 25. 25 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  26. 26. 26 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  27. 27. 27 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  28. 28. 28 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  29. 29. 29 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  30. 30. 30 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  31. 31. 31 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  32. 32. 32 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  33. 33. 33 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  34. 34. 34 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  35. 35. 35 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  36. 36. 36 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  37. 37. 37 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND
  38. 38. 38 LZW Decoding Word _ a b z 0 Index … 32 … 97 98 122 SEND … 256 STOP257 … it Word tt ty y_ _b bi ty_ _bi it_ _bin 258 Index 259 260 261 262 263 265 266 267 268 itt264 Dictionary 105 Received 116 116 121 32 98 260 262 i Input t t y _ b t t y _ 258 b i t 258 i 266 _ b i 110 n 257 STOP 256 SEND

×