Java icon indicating copy to clipboard operation
Java copied to clipboard

[FEATURE REQUEST] Huffman Coding Compression Algorithm

Open Shewale41 opened this issue 4 months ago • 2 comments

What would you like to Propose?

Title: Add Huffman Coding for Lossless Compression and Decompression


🧠 Overview

Implement Huffman Coding, a greedy algorithm used in file compression (ZIP, JPEG, etc.) that encodes data based on character frequency.

🧩 Problem Description

Given a string, generate prefix-free binary codes for each character based on frequency and compress the data efficiently.

📂 Implementation Details

  • Folder: src/main/java/com/thealgorithms/compression/
  • Filename: HuffmanCoding.java
  • Approach:
    • Count frequency of each character.
    • Build a min-heap tree based on frequency.
    • Generate variable-length codes (shorter for frequent characters).
    • Support encoding and decoding.

✅ Expected Deliverables

  • Complete implementation with encoder and decoder functions.
  • Example usage in main().
  • Unit tests verifying encoding-decoding accuracy.
  • Complexity analysis (O(n log n)).

🧑‍💻 Additional Notes

This algorithm is a foundational data compression technique that fits perfectly into the repository’s educational goals.

Issue details

🧩 Problem Description

Given a string, generate prefix-free binary codes for each character based on frequency and compress the data efficiently.

Additional Information

No response

Shewale41 avatar Oct 25 '25 13:10 Shewale41

Hi maintainers 👋 I’d love to implement this algorithm (Huffman Coding for Lossless Compression and Decompression). It follows the repository’s structure and standards — please assign it to me if available. Thank you! 😊

Mansi5164 avatar Oct 29 '25 13:10 Mansi5164

hey @Mansi5164 can you help me with the structure and standards for this repo's pr.I have made an pr also follow the clang format but still unable to tick all checks , i'll really appreciate if you tell me what are things i have to do to get passed in pr checks i have wrote the algorithm already but what are the other things i have to know or do so that my pr get passed.

Shewale41 avatar Oct 30 '25 06:10 Shewale41