240 likes | 1.1k Views
HUFFMAN CODING. Anvitha Banakal Sadananda Neha Matroja CSE-5311 November 30, 2010 University of Texas of Arlington. HUFFMAN CODING Technique. Huffman coding is a variable length encoding algorithm used for data compression. It is a greedy Algorithm.
E N D
HUFFMAN CODING Anvitha Banakal Sadananda Neha Matroja CSE-5311 November 30, 2010 University of Texas of Arlington
HUFFMAN CODINGTechnique • Huffman coding is a variable length encoding algorithm used for data compression. It is a greedy Algorithm. • For given frequency of characters, we assign codes in such way that the length of encoding is as minimum as possible. DATA STRUCTURES USED • Table • Priority queue • Binary Tree
0 1 0 1 0 1 R B A 0 1 D C HUFFMAN CODINGTechnique Cont’d ABRACADABRA Frequencies A : 5 B : 2 C : 1 D : 1 R : 2 Code A : 00 B : 10 C : 010 D :110 R : 11 Encoded : 001011000100001100101100 (24 Bits) ASCII 8* 11= 88 bits
HUFFMAN CODINGAlgorithm 1)Create a table with the fields : Serial No., Symbol , Weight, Representation 2) Create priority queue “Q”. Insert the symbols and frequencies in priority queue. 3) While there is more than one node in the queue: • 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) 4)Insert the representation in the HuffmanTree.
HUFFMAN CODINGCompression Ratio • Compression ratio = Bits of encoded characters/Bits of original characters • The running time of the algorithm is O(nlogn). Compression Ratio File size (No. of Characters)
REFERNCES : http://en.wikipedia.org/wiki/Huffman_coding http://www.graphviz.org/ http://www.experiencefestival.com/a/Data_compression/id/2000388 http://www.wordiq.com/definition/Huffman_coding http://paper.ijcsns.org/07_book/201005/20100520.pdf http://www.cs.utsa.edu/~wagner/laws/Ahuffmanc.html http://planetmath.org/encyclopedia/HuffmanCoding.html http://www.cs.duke.edu/csed/poop/huff/info/ http://www2.cs.usfca.edu/~galles/cs245S08/huffman08.pdf