https://github.com/maximilianfeldthusen/lzw
https://github.com/maximilianfeldthusen/lzw
algorithm c lzw-compression
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/maximilianfeldthusen/lzw
- Owner: maximilianfeldthusen
- License: bsd-3-clause
- Created: 2025-02-16T07:19:27.000Z (10 months ago)
- Default Branch: TFD
- Last Pushed: 2025-03-26T17:11:24.000Z (8 months ago)
- Last Synced: 2025-03-26T18:25:30.073Z (8 months ago)
- Topics: algorithm, c, lzw-compression
- Language: C
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Documentation
### LZW Compression Algorithm Implementation in C
A straightforward C code of the Lempel-Ziv-Welch (LZW) compression algorithm in C. LZW is a popular lossless data compression method that substitutes repeated data occurrences with references to a single instance.
Concepts
- LZW Compression: The algorithm constructs a dictionary of input sequences and replaces these sequences with shorter codes, thereby effectively minimizing the data size.
- Dictionary Initialization: The process begins with a predefined dictionary that includes all single-character strings.
- Dynamic Dictionary Expansion: New sequences are added to the dictionary as they are encountered.
- Code Representation: Each unique sequence is assigned a code, which is produced during the compression process.
The code is organized into several essential functions:
- initializeTable: Sets up the dictionary with entries for single characters.
- findCode: Looks for a string in the dictionary and returns its associated code.
- addEntry: Inserts a new string entry into the dictionary with a unique code.
- compress: Executes the LZW compression algorithm on the provided input string.
- freeTable: Releases the memory allocated for the dictionary entries.
- main: Serves as the program's entry point, initializing the dictionary, compressing a sample input, and managing resource cleanup.