Download presentation
Presentation is loading. Please wait.
Published byLillian Reynolds Modified over 9 years ago
1
Huffman Encoding and Decoding Sarker Tanveer Ahmed Rumee (1000672838) Md. Abdus Salam (1000667054)
2
Outline Problem definition The Huffman Algorithm Analysis of the Algorithm Implementation Results Conclusion
3
Problem Definition Take a text file as input Encode it so that- Less space is used to store the characters of this text No information is lost- we can reconstruct the original text
4
Huffman Algorithm Data Structure used: Priority queue = Q Huffman (c) n = |c| Q = c for i =1 to n-1 do z = Allocate-Node () x = left[z] = EXTRACT_MIN(Q) y = right[z] = EXTRACT_MIN(Q) f[z] = f[x] + f[y] INSERT (Q, z) return EXTRACT_MIN(Q)
5
Analysis of the Algorithm Q implemented as a binary heap. line 2 can be performed by using BUILD-HEAP in O(n) time. FOR loop executed |n| - 1 times and since each heap operation requires O(lg n) time. => the FOR loop contributes (|n| - 1) O(lg n) => O(n lg n) Thus the total running time of Huffman on the set of n characters is O(nlg n).
6
Implementation PLATFORM : Microsoft windows 9x,NT,2000,XP PROGAMMAING LANGUAGE : Java (J2SE) PROGRAMMING TOOL : Eclipse and NetBeans IDE Code implemented has two module : Encode (Compress) the input text/file. Decode (Decompress) the encoded file.
7
Results Performance criteria Compression Ratio (CR) The ratio is calculated using the following formula: CR = (Input File Size - Compressed File Size/Input File Size) * 100.0 We also show the top 12 most frequent characters found in the original input file and then match with ETAOIN SHRDLU – which is the 12 most frequent characters (sorted from highest to lowest frequencies) in English language. (Most commonly in newspapers)
8
Performance of Huffman Algorithm over various inputs File Type & Size in bytes Encoded File Size (in Bytes) Compression Ratio (%) Most Frequent 12 Characters 1. Basic Loren Ipsum Text (3,977) 208947.47 etaiosumrdln 2. Shakespear’s Play: Juleas Ceaser (129,909) 74,86442.37 etoasnrhildu 3. Random Html File [139,449] 91,46834.33ie atnsrol"/
9
Comparison with other efficient compression softwares FileHuffman Encoding [This Implementation] Win RarWin Zip File 147.4781.580.91 File 242.3765.5463.25 File 335.8364.463.84 NB :Values in the table indicate compression Ratio
10
Conclusion In the end, Huffman Algorithm is a good base to understand how the compression algorithm works. For data compression more sophisticated techniques are available now. Huffman algorithm can be modified to perform image compression.
11
Thank You
12
Questions ??
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.