Skip to content

[FEATURE REQUEST] feat(compression): Add LZW and Arithmetic Coding algorithms #6798

@Microindole

Description

@Microindole

What would you like to Propose?

I would like to propose adding implementations for the following fundamental lossless compression algorithms to the compression category:

  • LZW (Lempel–Ziv–Welch)
  • Arithmetic Coding

This will significantly enhance the collection of classic compression techniques available in the repository.

Issue details

Algorithm 1: LZW (Lempel–Ziv–Welch)

  • Problem Statement: LZW is a universal lossless data compression algorithm that works by building a dictionary of frequently used strings of data and replacing them with shorter codes.
  • Example:
    • Input: "TOBEORNOTTOBEORTOBEORNOT"
    • Output: [84, 79, 66, 69, 79, 82, 78, 79, 84, 256, 258, 260, 265, 259, 261, 263]
  • File Path: src/main/java/com/thealgorithms/compression/LZW.java

Algorithm 2: Arithmetic Coding

  • Problem Statement: Arithmetic coding is a form of entropy encoding that encodes an entire message into a single number, a fraction n where (0.0 <= n < 1.0). It can achieve higher compression ratios than Huffman coding.
  • Example:
    • Input: A string, e.g., "BABA" with symbol probabilities A: 0.5, B: 0.5.
    • Output: A single floating-point number representing the compressed data, e.g., 0.5625. The decompression process uses this number and the symbol probabilities to reconstruct the original string.
  • File Path: `src/main/java/com/thealgorithms/compression/ArithmeticCoding.java

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions