-
Notifications
You must be signed in to change notification settings - Fork 20.7k
Open
Labels
Description
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