Pastebin

Paste #42:

< previous paste - next paste>

Pasted by tdn

Download View as text

Huffman Algorithm
=================

1: Initialization: put all symbols on the list sorted according to their frequency counts.

2: Repeat until the list has only one symbol left:
   a: From the list, pick two symbols with the lowest frequency counts. Form a Huffman subtree that has these two symbols as child nodes and create a parent node for them.
   b: Assign the sum of the children's frequency counts to the parent and insert it into the list, such that the order is maintained.
   c: Delete the children from the list.

3: Assign a codeword for each leaf based on the path from the root.

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.