Skip to content

Conversation

enqneres
Copy link

Description

This pull request adds two classic lossless compression algorithms to the compression category:

LZW (Lempel–Ziv–Welch)

Builds a dictionary of strings and replaces repeating patterns with shorter codes.

Example:

Input: TOBEORNOTTOBEORTOBEORNOT
Output: [84, 79, 66, 69, 79, 82, 78, 79, 84, 256, 258, 260, 265, 259, 261, 263]

Arithmetic Coding

Encodes a message as a single number between 0 and 1 using symbol probabilities.

Example:

Input: "BABA" (A:0.5, B:0.5)
Output: 0.34375

Files added:

src/main/java/com/thealgorithms/compression/LZW.java

src/main/java/com/thealgorithms/compression/ArithmeticCoding.java

📚 Related issue: #6798

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java
@codecov-commenter
Copy link

codecov-commenter commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 0% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.68%. Comparing base (6b7d201) to head (fc2ea6c).

Files with missing lines Patch % Lines
...om/thealgorithms/compression/ArithmeticCoding.java 0.00% 18 Missing ⚠️
...c/main/java/com/thealgorithms/compression/LZW.java 0.00% 18 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## master #6803 +/- ## ============================================ - Coverage 77.82% 77.68% -0.15%  + Complexity 6392 6390 -2  ============================================ Files 732 734 +2 Lines 21320 21356 +36 Branches 4182 4189 +7 ============================================ - Hits 16592 16590 -2  - Misses 4059 4095 +36  - Partials 669 671 +2 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@enqneres
Copy link
Author

Anyone to approve my PR? Have I completed all the steps or am I missing any?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants