LZW

Vicente González Ruiz

January 7, 2020

Contents

1 Basics
2 Encoder
3 Decoder
4 Lab: LZW
References

1 Basics

2 Encoder

  1. w first input symbol.
  2. While the input is not exhausted:
    1. k next input symbol.
    2. If wk is found in the dictionary, then:
      1. w address of wk in the dictionary.
    3. Else:
      1. Output w.
      2. Insert wk in the dictionary.
      3. w k.

Example

3 Decoder

  1. c first input code-word.
  2. Output c.
  3. c c.
  4. While the input is not exhausted:
    1. c next input code-word.
    2. w c.
    3. If c is found in the dictionary, then:
      1. Output string(c).
    4. Else:
      1. Output string(w).
      2. Output k.
    5. k first symbol of the last output.
    6. Insert wk in the dictionary.
    7. c c.

Example

4 Lab: LZW

IPython notebook

References

[1]   Terry A. Welch. A technique for high-performance data compression. IEEE Computer, 17(52):8–19, 1984.