Giter Site home page Giter Site logo

huffman's Introduction

The Huffman coding

Usage

Huffman coding

  -s SAMPLE   --sample=SAMPLE   The set of symbols to use to create the tree
  -h          --help            Displays this help message
  -t          --tree, --dot     The tree in .dot format
  -a          --canonical       Use the canonical Huffman code for generating the codewords, encoding and decoding
  -c          --codewords       The list of the codewords
  -e MESSAGE  --encode=MESSAGE  Encodes a message
  -d MESSAGE  --decode=MESSAGE  Decodes a message

Printing Huffman trees

This executable allows you to print the representation of the binary tree using the dot syntax.

Example : huffman -s "this is a huffman tree" -t | dot -Tpng -o tree.png

The tree

Encoding/decoding examples

Encoding :

$ huffman -s "coucoutoi" -e "touco"
01111100011

Decoding :

$ huffman -s "coucoutoi" -d "01111100011"
touco

Getting the canonical codewords

The canonical Huffman code is a particular kind of huffman coding which makes it unique.

$ huffman -s "this is a huffman tree" -ca
  -> 000
i -> 100
s -> 101
t -> 110
a -> 1110
e -> 1111
f -> 1000
h -> 1001
m -> 1010
n -> 1011
r -> 1100
u -> 1101

huffman's People

Contributors

eloidrai 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.