@walkerrandolphsmith/huffman-tree

7.0.1 • Public • Published

Huffman Tree

    *
  /   \
e       *
      /   \
     n     s

Huffman tree is a type of tree that stores a elements that are accessed with an uneven distribution. Some elements are more frequently accessed than others and are therefore less expensive to retreive.

new HuffmanTree(comparator) Create a new Huffman Tree given a comprator.

add(element, code) Given an element and a bit string, add a node in the tree for the element such that the tree can be traversed using the bit string as a sequence of edges.

decode(code) Given a bit string, retrieve the element in the tree it corresponds to.

Package Sidebar

Install

npm i @walkerrandolphsmith/huffman-tree

Weekly Downloads

0

Version

7.0.1

License

ISC

Unpacked Size

5.67 kB

Total Files

5

Last publish

Collaborators

  • walkerrandolphsmith