LZW
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
It is the algorithm of the widely used Unix file compression utility compress and is used in the GIF image format.
Algorithm
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.
Example
TOBEORNOTTOBEORTOBEORNOT#