Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vishalkg/huffman_coding
https://github.com/vishalkg/huffman_coding
binary-heap cache-optimized-heap data-structures-algorithms encoder-decoder huffman-coding huffman-compression-algorithm huffman-reader huffman-tree huffman-writer java-8 pairing-heap
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/vishalkg/huffman_coding
- Owner: vishalkg
- Created: 2017-03-03T05:25:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-29T02:32:49.000Z (over 7 years ago)
- Last Synced: 2024-07-31T00:34:51.293Z (5 months ago)
- Topics: binary-heap, cache-optimized-heap, data-structures-algorithms, encoder-decoder, huffman-coding, huffman-compression-algorithm, huffman-reader, huffman-tree, huffman-writer, java-8, pairing-heap
- Language: Java
- Homepage:
- Size: 31.2 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Huffman Coding
Given a frequency data, produces huffman codes for the unique messages.* Node.java: DS for storing huffman tree
* PairNode.java: DS used in PairingHeap.java
* BinaryHeap.java: To implement binary heap
* PairingHeap.java: To implement pairing heap
* D_aryHeap.java: To implement D-ary heap. For eg. 4-way heap.
* Gen_huffman_code.java: To comapre the performance of above mentioned priority queues for huffman coding.Usage:
```
~:src$ java Gen_huffman_code ../sample_input_large.txt
Reading input file ... Building Freq Table ... Done.
Building Huffman Tree using Binary Heap ...
Run:1.. 2.. 3.. 4.. 5.. 6.. 7.. 8.. 9.. 10.. Done
Average Time: 1663.0
Building Huffman Tree using Pairing Heap ...
Run:1.. 2.. 3.. 4.. 5.. 6.. 7.. 8.. 9.. 10.. Done
Average Time: 3417.0
Building Huffman Tree using 4-ary Heap ...
Run:1.. 2.. 3.. 4.. 5.. 6.. 7.. 8.. 9.. 10.. Done
Average Time: 1291.0
```It is found that 4-ary heap is the fastest. So later encoding is done using 4-ary heap.
* encoder.java: Produces code_table.txt containing codes for all the unique messages; and encoded.bin, which is the binary file for the codes corresponding to the input file.
Usage:
```
~:src$ java encoder ../sample_input_large.txt
Reading input file ...
Building Freq Table ...
Building huffman tree... Done.
Generating code_table.txt .. Done.
Generating encoded.bin .. Done.
```As a proof of concept, we will reconstruct our input using code_table.txt and encoded.bin
* decoder.java: Takes in input encoded.bin and code_table.txt and produces decoded.txt which is exactly the same as sample_input_large.txt as used in encoder.
Usage:
```
~:src$ java decoder encoded.bin code_table.txt
Building huffman tree from code_table.txt ..
Reading code_table.txt .. Done.
Reading encoded.bin .. Done.
Generating decoded.txt .. Done.
```Do `diff decoded.txt ../sample_input_large.txt` to check correctness.
Clone repository and make:
```
~:$ git clone https://github.com/vishalkg/huffman_coding.git
~:$ cd huffman_coding/src
~:src$ make
```