Skip to content

Commit cc4d78f

Browse files
authored
Add files via upload
1 parent fe9fcd9 commit cc4d78f

File tree

10 files changed

+774
-0
lines changed

10 files changed

+774
-0
lines changed

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Makefile for compiling huffman.c
2+
3+
# Compiler
4+
CC = gcc
5+
6+
# Compiler flags
7+
CFLAGS = -Wall -O2
8+
9+
# Source file
10+
SOURCE = huffman.c
11+
12+
# Output executable
13+
OUTPUT = huffman
14+
15+
# Default target
16+
all: $(OUTPUT)
17+
18+
# Rule to build the executable
19+
$(OUTPUT): $(SOURCE)
20+
$(CC) $(CFLAGS) -o $(OUTPUT) $(SOURCE)
21+
22+
# Clean target
23+
clean:
24+
rm -f $(OUTPUT)

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Huffman Tree Processing Tool
2+
## Overview
3+
The Huffman Tree Processing Tool (huffman.exe) is a command-line utility written in C that facilitates Huffman coding and decoding. The tool supports three main modes: Build Tree, Encode, and Decode.
4+
5+
## Features
6+
### 1. Build Tree Mode
7+
In this mode, the tool constructs a Huffman tree based on the weights of input characters. The user provides a file containing character weights, and the resulting model is saved to a specified output file. The tool outputs the size of the code table and the Weighted Path Length (WPL) on the screen.
8+
9+
**Usage:**
10+
11+
```bash
12+
# format of input file
13+
A 0.03
14+
B 0.028
15+
C 0.035
16+
```
17+
18+
```bash
19+
# order in terminal
20+
./huffman.exe -m c -i input_file -o model_file
21+
```
22+
23+
### 2. Encode Mode
24+
The Encode mode allows users to encode text using a pre-built Huffman tree model. Users provide a text file in .txt format with a single row without a line break, the Huffman model file, and the tool outputs the encoded result to a specified file.
25+
26+
**Usage:**
27+
28+
```bash
29+
./huffman.exe -m e -i input_file -h model_file -o output_file
30+
```
31+
32+
### 3. Decode Mode
33+
In Decode mode, the tool takes an encoded file and the Huffman code file, then decodes the input and outputs the result to a specified file in .txt format.
34+
35+
**Usage:**
36+
37+
```bash
38+
./huffman.exe -m d -i input_file -h code_file -o output_file
39+
```
40+
41+
## Usage Examples
42+
### Build Tree Mode
43+
```bash
44+
./huffman.exe -m c -i weight.txt -o model.txt
45+
```
46+
47+
### Encode Mode
48+
```bash
49+
./huffman.exe -m e -i origin.txt -h model.txt -o encode.txt
50+
```
51+
52+
### Decode Mode
53+
```bash
54+
./huffman.exe -m d -i encode.txt -h model.txt -o decode.txt
55+
```
56+
57+
## Dependencies
58+
The tool is written in C and does not have external dependencies, orders should be input in terminal in the same direction.
59+
60+
## Compilation
61+
To compile the tool, use the provided Makefile or any C compiler, such as GCC.
62+
63+
To compile your huffman.c program in linux environment with provided Makefile, open the terminal in the same directory and run:
64+
65+
```bash
66+
make
67+
```
68+
This will create an executable named huffman in the same directory. If you want to clean up and remove the executable, you can run:
69+
```bash
70+
make clean
71+
```
72+
Make sure to adjust the CFLAGS variable if you have additional compilation flags you'd like to include.
73+
74+
## Contributing
75+
Feel free to contribute by opening issues or submitting pull requests on the GitHub repository.
76+
77+
## License
78+
This Huffman Tree Processing Tool is an open-source.

decode.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In the intricate tapestry of existence, each fleeting moment weaves its own narrative, and every choice resonates like a ripple through the vast ocean of time. Life, a kaleidoscope of joy and sorrow, is a perpetual dance between light and shadow, where the symphony of experiences shapes the melody of our journey. Amidst the labyrinth of uncertainty, the pursuit of meaning becomes a compass guiding us through the uncharted territories of purpose. Embracing the ephemeral nature of our existence, we find solace in the realization that the beauty of life often lies in its impermanence. Like a delicate flower that blooms only to wither, our moments are precious, and it is in cherishing them that we uncover the profound artistry embedded in the fabric of our being. As we navigate the complex corridors of time, let us cultivate compassion, sow seeds of kindness, and paint our days with the hues of love, for in these simple yet profound acts, we discover the essence of a life well-lived.

encode.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
01010001011100100000110111110010010001000111110101110011011111010111111011101110001101110010001000001101101110100110100100001011001101111101011011100001000011011101010010001001000110010111110001011001101110010010111101111001001010110010001001001110101111110000100010101001010100101001000110111111101011111001001000010010011011010010100100101110011011001000111011110010011101001110100100001011001000111110011011000101100100001101111101110101110010000101110111011101011101001110001101111111100111010010010101100100001110010111110100010001001010011101001011101011011100001000101111110001101111111101111001000100011101010010000101101101101011101110001101110010000101100100000101011111000111100100010000111000100011101011111100110100110001010100100010000011011111001110100110110110001110011110000100000110111110010010001000100111001110000101100110110010000110111011110010011100101110010000110111010100100000110111111101001010010000011100100010110011111101011001001010110010000111000100000011101110001010100101111111010011011000101110111011011100110100100010000110111010100100000001001101111011100001000011100101111101000100000010110110111110101110100110111110111010101100100011111000101100100001110001000100110100101110101001101001000110110110001011100010100010001101001110010111101111001000100010001100100011011111011110010100100101110010000010101111111001111000011011001000011100101111101000100000010111110001110110100110111110111010101100100011101111110010010111010100100010000011011111001001000100000010111101110001001010011011100011011010111110111000010000110111010100100010010001100101001101001011101011111100100101111011110010000101100100000010111110001110100110100100001011001000001101111100100100010000100101001000101001101111010110111000010000110111010100100001101101100011110100010000000100110110110001111010010111100101101110000001110010000100010100101111111010000101100110110010000011011111001001000100000101001110100011101110011101011111010111001101111100001000011011101010010000110001010111101111001011101000110110111011111010111001101111011100010101100100000110111110010010001000100110011000111101000010110110001111110011011001000011011101010010000100101001001110010111111110101111100100100010001100101011101101101001010010000101100100001110001000101110110110100101001100111000010110001011001000110010110001111111101011111010111110010010000110001000101100100000110111110011101001101101100011100111100001000001101111100100100010000110001010111101111110001110111010001101110010110100010000011011100101110101110101111100110110110111110101111110010000101100100001101110101001000100110011000111101010011001101100010111001000001110010000000010100101000111101001110101111111101011111001001000001101111100100100010001001010011011100100100100101001011101001110001010001000010111011100011011011000111101010010001000011011101010010000110110110001111010001000100100011001011111000101100110111001001011110111100100101011001000111011110010001000101011111101011111010001000000101101101100101001110101111001000100011111010111001000001101111100100100010001110101001001110001010111110011000110111000110111111101101101011100100000110111110001110001101100100000110111110010010001000100011001001110011000100110111101110000100001101110101001000001010111111010110010001000011011101010011011100100101110010000010101111110010000101100100011111010111001000111110011011000101100100011111010010100110100101110100100100111001011110010010111101111001000001110010001011001111100011110010001000011100010001101010010001010111111011101110001101110010001000101010010100110111110111100101110100010000011011111000111000110110010001000100101001101101101101001000010110010000110110101110010101101110000100000110110110110010001110111111110011011111001001011101001010110010000110110110001111010001000010010011011010010100100101110011011000101100100001110111010100100010001001101110101001010111111110110110110001000101101010110010000111001011111010001000111110011011001000111110001011001000111110101110010001011111100100101110101111100010111110011111010111110010010000011011111001001001001000100000110111110001110001101100100011101111001000100001100010101111011101101110011101001011101000100000110111110010010001000100110111010011011101010110110110001010111110100010000111011101000110111111100010110011011111010110111000010001001001001010001100101101011010100101101000100011111010111001000001101111100100100010001010101110100011110101111110111001000011011101010010000110110110001111010001000100011001011111010111110010000111001000010001000101100100011101111001000100001011101110100111011111110010111000110111001000100000110111110010010001000101110110110100101001100010101001000110010001000101110110111110101110101111111010011011111010000101100100001101110101001000001101111111010010100100101011001000001010100100011011001000011000100010110010001011101100010010100011011111111001110011100011011100100010001011101101101001010011001110000101100010111111101101101011101010110010000001011011011111011100100000010111001010010110100001011001000011011101010010000001111111101011111010010111100100001011000101101010110010000111001011111010001000100110011101111101011100110110010000110110110001111010001000110100111011011100000101100100011101111111100110111110000100000110111110010010001000111000110001100100001011001000011011101010010000010100110111001110100100101011001000101010110111110100010001111101011100100000110111110010010000101110010001000000101111111010010100110001010100100010001101110010010001101100100010011011101001101110101011011011000101011111010001000011101011100110110001011010101100100011101111001000100011010111110001011101110110111001110100101110100010000011011111001001000100010010000101100010111001001011110111100100010000110111010100100001110001000001010111111010110010001000111011110010001010001010100000100101011111100111010010110100000111

0 commit comments

Comments
 (0)