{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

huffman

# huffman - Huffman Coding Trees Huffman Coding is a method...

This preview shows pages 1–2. Sign up to view the full content.

Sheet1 Page 1 Huffman Coding Trees ------- ------ ----- Huffman Coding is a method of compressing data. It is based on specialized binary trees, which we will call Huffman Coding Trees. A Huffman Coding Tree for (compressing) the string `abaacb' is made as follows. First, make single node trees for each character appearing in the string, and assign each tree a `weight' equal to the number of times the character appears in the string. We get the three single node trees: a/3b/2c/1 where `a', `b', and `'c' are the names of the single node trees and 3, 2, and 1 are their weights. Next we select the two trees with the lowest weights and replace them both by a single larger tree made by adding a root node whose two children are the two trees being replaced. In this case we get (b)(c)/3 where the name of a tree with two children is written: (left-child-name)(right-child-name) and the weight of the new tree is the sum of the weights of its children. In this case `b' is the left child, `c' is the right child, and 3=2+1 is the new weight. After this first tree replacement we are left with two

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

huffman - Huffman Coding Trees Huffman Coding is a method...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online