Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. The algorithm is simple to implement, and has the potential for very high throughput in hardware implementations. It was the algorithm of the widely used Unix file compression utility compress, and is used in the GIF image format.Its works like index backside of our notebook.
- I am taking string pattern for elaboration to show compression.
- Add chosen character into dictionary and assign them an index
- Make sure before enter string into dictionary that it’s not appeared twice.
- If string is already in dictionary then change input and again check whether its in dictionary or not if not then add and assign an index
[Consider index 6, 7 its entry is AB & CD because if we took ABCD the we get that its on index 1. so changed input as AB & CD]