Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch.
It was published by Welch in 1984 as an improved implementation of the LZ78 (LZH) algorithm published by Lempel and Ziv in 1978. Its most important use is the popular GIF format.
 How it works
A dictionary of previous values are used for repeated data instead of reentering the data. A high level view of the encoding algorithm is shown here:
- Initialize the dictionary to contain all strings of length one.
- Find the longest string W in the dictionary that matches the current input.
- Emit the dictionary index for W to output and remove W from the input.
- Add W followed by the next symbol in the input to the dictionary.
- Go to Step 2.