Coder Social home page Coder Social logo

huffman-coding-in-c's Introduction

Huffman-Coding-in-C

Implementing Huffman Coding in C Huffman Coding is a lossless compression, meaning no data is loss during the compression. It achieved it by changing the encoding of each characters after analysing the frequecies of each characters. This allow more frequent characters to be encoded using shorter encoding, which reduces the file size.

----------Training----------

  1. Reads the file.
  2. Update character frequencies for each character.
  3. Create a binary tree with least frequencies characters at the deepest.
  4. Create a table containing encoding for each characters after tree traversal.

----------Encoding----------

  1. Reads the input file.
  2. Check the table for the encoding and write it into the output file. This is due to the encoding not having the same sizes. We are buffering the code, and writing it down byte by byte using bitset. That would allow us to write down codes that has length not multiple of byte(s) without wasted space.

---------Decoding-----------

  1. Reads the input file.
  2. Reads bit by bit.

3.0 If there is a match after comparing the the table, write the corresponding character into the output file. 3.1 If there is no match, buffer the bit and read another bit and add it after the buffered bit(s). Repeat 3.0

Thanks for Lexes for helping me.
Lexes: https://github.com/lexesjan Credit to David for providing make/test files. David: https://www.scss.tcd.ie/David.Gregg/

huffman-coding-in-c's People

Contributors

dabreadman avatar

Watchers

 avatar

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.