16-Huffman_Code

# 16-Huffman_Code - Huffman code uses different number of...

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

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

View Full Document

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

View Full Document

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.

Unformatted text preview: Huffman code uses different number of bits to represent characters:- fewer for frequent characters - more for rare characters. Example: e = 10, z = 1001101 Huffman codes are used for data compression. Huffman Code Huffman Code Huffman Tree is a binary tree where:- leafs store characters- left edges are associated with zeros- right edges are associated with ones. Huffman Tree Huffman Tree To determine Huffman code of a character given a pre-built Huffman Tree:- traverse the tree from root to leaf until you find the character- keep the record of left or right turns to make up the code, e.g. a = 000 b = 001 Huffman Codes Huffman Codes For each character in the message:- obtain Huffman Code- concatenate character codes to form the encoded message (bit string). Example: abe -> 000001100 a b e Huffman Encoding Huffman Encoding For each bit in the Huffman Code bit string:- recursively traverse the Huffman Tree starting from the root; use the bit’s value to decide whether to traverse the left sub-tree or the right sub-tree...
View Full Document

{[ snackBarMessage ]}

### Page1 / 9

16-Huffman_Code - Huffman code uses different number of...

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

View Full Document
Ask a homework question - tutors are online