This repository contains a Python implementation of the Lempel-Ziv-Welch (LZW) algorithm for data compression and decompression. The algorithm dynamically builds a dictionary to encode and decode variable-length input efficiently.
- Encoding: Compresses input strings into numeric codes.
- Decoding: Reconstructs the original string from the codes.
- Dynamic Dictionary: Handles variable-length inputs with a growing dictionary.
- Install Python 3.x from python.org.
- Save the script as
lzw_compression.py
. - Open a terminal and run:
python lzw_compression.py
- Enter a string when prompted to see the encoded and decoded results.
Enter a message to encode: hello world
- Encoded: [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
- Decoded: hello world
- File compression for storage efficiency.
- Data transmission over networks.
- Lossless compression for text processing.