ObjectivesWhat are Huffman Codes ?Why Huffman Codes are used ?
IntroductionAn effective and widely used Application ofBinary Trees and Priority QueuesDeveloped by David.A.Huffman while he was a Ph.d student at MIT andpublished in the 1952 paper “A Method for the Construction of MinimumRedundancy Codes”.Each code is a binary string that is used for transmission of thecorresponding message.For Example : BAGGAGE 100 11 0 0 11 0 101 Plain Text Huffman Code
Major Steps baggage1. Prepare the frequency table.2. Construct the binary tree. Alphabets Frequencies3. 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
Algorithmn <- |C|Q <- Cfor 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)
AnalysisTime Complexity: Time complexity of Huffman algorithm is O(nlogn) where eachiteration requires O(logn) time to determine the cheapest weight and therewould be O(n) iterations.
Applications Of Huffman CodingSupports 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.
ConclusionLike many other useful algorithms we do require Huffman Algorithm forcompression of data so it could be transmitted over internet and othertransmission channels properly.Huffman algorithm works on Binary trees. Huffman DATA Huffman Code Algorithm