Presentation is loading. Please wait.

Presentation is loading. Please wait.

Madivalappagouda Patil

Similar presentations


Presentation on theme: "Madivalappagouda Patil"— Presentation transcript:

1 Madivalappagouda Patil
Huffman coding Madivalappagouda Patil

2 Introduction used for compressing the data
uses the table of frequencies of occurrence of characters each character is represented by a binary string Two ways Fixed length code Variable length code

3 Take the characters and their frequencies, and sort this list by increasing frequency
All the characters are vertices of the tree Take the first 2 vertices from the list and make them children of a vertex having the sum of their frequencies Insert the new vertex into the sorted list of vertices If there are at least 2 vertices in the list, fallow the above steps. Read the Huffman code from the tree

4 The (Real) Basic Algorithm
An Introduction to Huffman Coding March 21, 2000 The (Real) Basic Algorithm 1. Scan text to be compressed and tally occurrence of all characters. 2.Sort or prioritize characters based on number of occurrences in text. 3.Build Huffman code tree based on prioritized list. 4. Perform a traversal of tree to determine all code words. 5. Scan text again and create new file using the Huffman codes. CS 102 Mike Scott

5 n=|C| Q=C for i=1 to n-1 Z=new tree node left=(z)=Extract Min(Q) Right=(z)= Extract Min(Q) frequency(z)=frequency(x)+frequency(y) Insert(Q,z) Return Extract Min(Q)

6 Example

7

8

9

10 Summary Huffman coding is a technique used to compress files for transmission Uses statistical coding more frequently used symbols have shorter code words Works well for text and fax transmissions An application that uses several data structures CS 102

11 Thank you


Download ppt "Madivalappagouda Patil"

Similar presentations


Ads by Google