Giter VIP home page Giter VIP logo

huffman-coding-file-zipper's Introduction

Huffman-Coding-File-Zipper

Overview

This project uses Huffman Coding, a lossless compression algorithm, to compress and decompress text files.

Node Structure

A Node in the Huffman Tree contains:

  • Character data
  • Frequency of the character
  • Huffman code
  • Pointers to left and right child nodes

Huffman Class

The Huffman class includes:

  • Constructor: Accepts input and output file names
  • compress(): Compresses the input file
  • decompress(): Decompresses the Huffman coded file image

Compression Steps (compress())

  1. createMinHeap(): Reads the input file, calculates character frequencies, and creates a Min Heap.
  2. createTree(): Builds the Huffman tree using the Min Heap.
  3. createCodes(): Traverses the Huffman tree to assign binary codes to characters.
  4. saveEncodedFile(): Saves the encoded file with Huffman codes and the encoded input file. image

Decompression Steps (decompress())

  1. getTree(): Reconstructs the Huffman tree from the encoded file.
  2. saveDecodedFile(): Reads the encoded input file, converts Huffman codes back to characters, and saves the original file. image

Result

image image image

This project is just an implementation of Huffman coding, it is not as efficient as the compression algorithm used currently to compress files. Example: inputFile.txt (2.2MB) is compressed to compressedFile.huf (1.1MB) file and decompressed back to ouputFile.txt (2.2MB).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.