Lempel-Ziv-Welch (LZW) encoding is patented, thus we cannot show
you a working example. However, the basic algorithm is
well-documented on various websites including Wikipedia. If you can
follow the algorithm, you can write the code. But you cannot
distribute the code without the requisite licence.