120 likes | 337 Views
Huffman Encoding and Decoding. Sarker Tanveer Ahmed Rumee (1000672838) Md. Abdus Salam (1000667054). Outline. Problem definition The Huffman Algorithm Analysis of the Algorithm Implementation Results Conclusion. Problem Definition. Take a text file as input Encode it so that-
E N D
Huffman Encoding and Decoding SarkerTanveer Ahmed Rumee (1000672838) Md. Abdus Salam (1000667054)
Outline • Problem definition • The Huffman Algorithm • Analysis of the Algorithm • Implementation • Results • Conclusion
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
Huffman Algorithm • Data Structure used: Priority queue = QHuffman (c)n = |c|Q = cfori =1 to n-1do 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)
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 timeof Huffman on the set of n characters is O(nlg n).
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.
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)
Comparison with other efficient compression softwares NB :Values in the table indicate compression Ratio
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.