✨ Description:
This project implements the Huffman Encoding algorithm in C# .NET 6.0 using memory-friendly data types such as lists and arrays.
With lossless compression, your data takes up less space and transfers faster.
- 📜 About the Project
- ⚡ Features
- 🧩 Algorithm Overview
- ⚙️ Installation and Usage
- 📊 Sample Output
- 🛠 Technologies
- 🤝 Contributing
- 📄 License
- 📬 Contact
Huffman Encoding is a lossless compression algorithm that encodes data based on character frequencies.
This project:
- 🔍 Calculates character frequencies
- 🌲 Builds combinations using Huffman tree logic
- 🔢 Generates variable-length bit codes per character
- 📉 Reports bit comparison and compression ratio before and after compression
✅ Detailed frequency analysis
✅ Code generation based on merging steps
✅ Bit-level compression length calculation
✅ Size comparison before and after compression
✅ Console output of processing times and code lists
- Calculate the frequency of each character in the input string.
- Sort characters by frequency in ascending order.
- Merge the two lowest-frequency characters to build the Huffman tree.
- Assign unique bit sequences to each character by traversing the tree (0 = left, 1 = right).
- Encode the text using these bit sequences for compression.
- Calculate compression ratio and processing time.
- 📥 Clone the repository:
git clone https://github.com/leventDemirkaya/huffmanEncoding.git cd huffmanEncoding
babadedefaca
| Character | Frequency | Huffman Code |
|---|---|---|
| a | 4 | 0 |
| b | 2 | 101 |
| d | 2 | 100 |
| e | 2 | 111 |
| f | 1 | 1101 |
| c | 1 | 1100 |
-
⏱ Processing Time: 0.0001 seconds
-
📦 Before Compression: 104 bits
-
📦 After Compression: 68 bits
-
📉 Compression Ratio: 34% savings
-
📝 Compressed Data 1010010101001111001111101011000
- 💻 C#
- 🖥 .NET 6.0
- 📂 Console application (single entry point: Program.cs)
💡 Contributions are very welcome!
- 🐛 Report issues via the Issues page
- 🚀 Submit pull requests for improvements
📝 This project is licensed under the MIT License. See the LICENSE file for details.