Upcoming SlideShare
×

# Huffman's Alforithm

888 views

Published on

Published in: Education, Technology, Business
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total views
888
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
78
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Huffman's Alforithm

1. 1. Huffman’s Algorithm
2. 2. What is Huffman’s Algorithm?  Huffman’s algorithm is a method for building an extended binary tree with minimum weighted path length from a set of given weights It is technique for compressing data.
3. 3. What is Huffman’s Algorithm? Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based on the frequencies of corresponding characters. The most frequent character gets the smallest code and the least frequent character gets the largest code.
4. 4. Tree Construction Rules • There are mainly two major parts in Huffman Coding 1) Build a Huffman Tree from input characters. 2) Traverse the Huffman Tree and assign codes to characters • 1. 2. 3. Steps to build Huffman Tree Create a leaf node for each unique character Extract two nodes with the minimum frequency Create a new internal node with frequency equal to the sum of the two nodes frequencies. 4. 4. Repeat steps#2 and #3 until the heap contains only one node. The remaining node is the root node and the tree is complete
5. 5. Huffman Tree Construction A 3 C E H I 5 8 2 7
6. 6. Huffman Tree Construction A H 3 2 5 C 5 E 8 I 7
7. 7. Huffman Tree Construction E H 3 2 C 5 5 10 I 8 A 7
8. 8. Huffman Tree Construction E H 3 I 8 A 7 2 C 15 5 5 10
9. 9. Huffman Tree Construction A H 3 2 1 5 C E I 5 0 8 7 0 1 1 0 15 10 0 1 25 E I C A H = = = = = 00 01 10 111 110