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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/29/2011 for the course IT 201 taught by Professor K.v.arya during the Spring '11 term at IIT Kanpur.

Page1 / 3

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online