Skip to content

This is the second project of COMP336 Algorithms course in BZU. It illustrates Huffman coding algorithm in compressing and decompressing files.

Notifications You must be signed in to change notification settings

MaysHroub/huffman-compression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Huffman Compression Tool 🗜️

Overview

This project implements the Huffman coding algorithm to compress and decompress files of any type. While Huffman coding is efficient for many scenarios, it's important to note that it may occasionally increase the size of certain compressed files due to the nature of encoding.

The tool was developed using Java and features a user-friendly graphical interface built with JavaFX.

Unlike many other implementations, this project minimizes the use of strings, which are resource-intensive in terms of both memory and processing time, to improve its performance.

Header of Compressed file

The header contains the following information:

  1. Original File Extension.
  2. Number of Padding Bits.
  3. Header Size (in bits).
  4. Huffman Tree Structure.

The Huffman tree is stored using the Standard Tree Format (STF) in post-order traversal. Internal nodes are encoded as 0, while leaf nodes are encoded as 1 followed by the byte value.

Tree Decoding Algorithm

A Stack is used to decode the tree format.

  1. If you encounter 1, read the byte value, create a node, and push it onto the stack.
  2. If you encounter 0, pop two nodes (pop right and pop left), create a parent node, and push it back onto the stack.
  3. The stack's final node is the root of the Huffman tree.

Features

  • Friendly User Interface: Easy-to-navigate GUI for seamless interaction.
  • Compression Statistics: Provides insights about compression efficiency.
  • Accurate Decompression: Ensures files are restored to their original state.
  • Efficient I/O Operations: Uses buffered reading and writing for performance optimization.

Screenshots

Start Screen

start screen

Compressing a file

compressing

Statistics of compression

stats

Huffman Coding Table

table

Header of Compressed file

header

Decompressing a file

decompressing

Demo Video

Click me to see the demo (⌐■_■)

Resources

This project was developed with the help of the following resources:

  1. Huffman Howto
  2. 12. 18. Huffman Coding Trees - OpenDSA

About

This is the second project of COMP336 Algorithms course in BZU. It illustrates Huffman coding algorithm in compressing and decompressing files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published