3. Introduction
An effective and widely used Application of
Binary Trees and Priority Queues
Developed by David.A.Huffman while he was a Ph.d student at MIT and
published in the 1952 paper “A Method for the Construction of Minimum
Redundancy Codes”.
Each code is a binary string that is used for transmission of the
corresponding message.
For Example :
BAGGAGE 100 11 0 0 11 0 101
Plain Text Huffman Code
4. Major Steps
baggage
1. Prepare the frequency table.
2. Construct the binary tree. Alphabets Frequencies
3. Extract the Huffman Code from the tree. b 1
a 2
g 3
Binary Tree e 1
This Huffman Code is
now used for the
transmission of word
“baggage”.
Huffman Code 100 11 0 0 11 0 101
b a g g a g e
5. Algorithm
n <- |C|
Q <- C
for i <- 1 to n-1
do allocate a new node z
left [ z ] <- x <- EXTRACT-MIN (Q)
right [ z ] <- y <- EXTRACT-MIN (Q)
f [ z ] <- f [ x ] + f [ y ]
INSERT(Q, Z)
return EXTRACT-MIN (Q)
6. Analysis
Time Complexity:
Time complexity of Huffman algorithm is O(nlogn) where each
iteration requires O(logn) time to determine the cheapest weight and there
would be O(n) iterations.
7. Applications Of Huffman Coding
Supports various file type as:
ZIP (multichannel compression including text and other data types)
JPEG
MPEG (only upto 2 layers)
Also used in steganography for JPEG carrier compression.
8. Conclusion
Like many other useful algorithms we do require Huffman Algorithm for
compression of data so it could be transmitted over internet and other
transmission channels properly.
Huffman algorithm works on Binary trees.
Huffman
DATA Huffman Code
Algorithm