https://github.com/theweird-kid/huffman-coding
Simple huffman Coding Implementation in C++
https://github.com/theweird-kid/huffman-coding
cpp20 data-compression huffman-compression-algorithm information-theory
Last synced: 10 months ago
JSON representation
Simple huffman Coding Implementation in C++
- Host: GitHub
- URL: https://github.com/theweird-kid/huffman-coding
- Owner: theweird-kid
- Created: 2024-10-31T09:05:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-31T09:10:15.000Z (about 1 year ago)
- Last Synced: 2025-02-12T18:46:40.824Z (12 months ago)
- Topics: cpp20, data-compression, huffman-compression-algorithm, information-theory
- Language: C++
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Huffman Coding
Huffman Coding is a lossless data compression algorithm. It assigns variable-length codes to input characters, with shorter codes assigned to more frequent characters. This project implements Huffman Coding in C++.
## Features
- Build Huffman Tree from input text
- Generate Huffman Codes for characters
- Encode text using Huffman Codes
- Decode encoded text back to original text
- Log compression details including original size, compressed size, and compression ratio
- Display binary representation of encoded string
## Getting Started
### Prerequisites
- C++ compiler with C++20 support (e.g., `g++`)
- Make utility
### Building the Project
1. Clone the repository:
```sh
git clone https://github.com/theweird-kid/huffman-coding.git
cd huffman-coding
```
2. Build the project using `make`:
```sh
make hc
```
### Running the Project
1. Run the executable:
```sh
./main
```
### Cleaning Up
1. Clean the build artifacts:
```sh
make clean
```
## Usage
Replace the `text` variable in `main.cc` with your input text. The program will output the encoded string, decoded string, and compression details.
### Example
```cpp
std::string text = "your text here";