 Hello everyone. Welcome to this session. I am Mr Praveen Yalapa Kumbar. Today we want to see Huffman coding. The learning outcome of this topic is at the end of this session student will be able to explain the concept of Huffman coding algorithm in lossless compression algorithm. The contents of this topics are introduction. After that one we want to see algorithm steps, Huffman code that is a creating tree, Huffman coding example. After that one we want to see Huffman decoding and after that one from this decoding we want to see Huffman coding properties. Now first introduction. Huffman coding was firstly presented by scientist Huffman in 1952. This method attracted an overwhelming amount of research. It has been adopted in many important and commercial applications such as fax machine, JPEG and MPEG images. In Shannon-Fano encoding steps which is now everyone pause the video and recall the steps of Shannon-Fano encoding. Okay it is from top to down but in Huffman algorithm it was opposite to the Shannon-Fano encoding that is from bottom to up manner. Now we want to see one by one the algorithm steps of Huffman coding. Now first initialization. In that initialization steps put all the symbols on the list sorted according to their frequency counts. Second repeat until the last has only one symbol left. In this case from the list pick up two symbols with the lowest frequency counts from a Huffman subtree that has these two symbols as a child nodes and create a parent node for them. After that one assign the sum of the children's frequency counts to the parent and insert it into the list such that order is maintained. After that one delete the children from the list and third one is assign a code word for each leaf based on the path from the root. Now we want to see Huffman code that is creating tree. In the previous slide whatever we see the steps of algorithm that we want to sorted here. In this algorithm first of all place each symbol in the leaf. In that one weight of the leaf is equal to the symbol of frequency. After that one select the two trees left and right initially leaves. After that one such that L and R have the lowest frequency in the trees. Create a new internal node where left child is represented by L, right child is represented by R and new frequency is equal to the summation of frequency that is L plus frequency that is R and repeat until all the nodes merge into the one tree. Now this algorithm we can understood with the help of the example. Now we want to see one Huffman coding example. Now first of all Huffman tree construction this is step one. Here first of all we sort out here we take an example of A, C, E, H and I. These are the symbols and I want to write here the frequency of that symbols. For the A the frequency is 3, for C the frequency is 5, for E the frequency is 8 and for H the frequency is 2 and for the I this is the frequency is 7. In that example first of all we want to write the frequency of the these symbols. After that one we want to make a combination of these two symbols because this frequency is very low as compared to the all others symbols. Therefore for A and H I want to combine first for the A frequency is 3 and for the H frequency is 2 that these two frequencies is very less as compared to these three symbols. Therefore first of all I will take A and H. After the combining of this A and H that is the frequency of A is 3, the frequency of H is 2, the combining of these two symbols become as 3 plus 2 is 5. In the next step of one tree construction 3 this is the previous step which we got it and for this next step I want to add C because the remaining symbols in the from the previous step is C, E and I. Now if you observe the frequency of C is 5, the frequency of E is 8 and the frequency of E is 7. Therefore I will take whichever having the low frequency. Now if you observe in this C, E and I the frequency of C is very low therefore I will take here C and adding this one 5 and the C is a 5 it becomes 10. Now in the next step this is a this is a one tree and I want to make out another tree in this one the symbol E and I that is the frequency is 8 and the frequency is 7. I want to combine these two frequencies and it become as a 15. Now in the half one tree construction 5 I want to add these all the symbols into this one whichever I got in the previous steps that is the A, H, C, E and I will add after that word I will get 10 plus 15 that is a 25 after that one I want to write left indicates by 1, right indicates by 0. In this way I will do the half one tree construction. Now if you observe the code for this each word now I want to calculate the code word for the E. Now according to the steps algorithm I will go from bottom to top. Therefore for the E if I if you observe E is present at the right side of the symbol therefore it will come first 0 and after that one it will goes to the 1 therefore E symbol is 0, 1 and the similarly we apply for I therefore they apply for the I it will come from bottom to the top that is 0 and 0 that is 0, 0 and for the according to that one if you apply for the C it will for the C it will come for 1 and 0 for the A it will come 1, 1, 1 and for the H it will come 1, 1 and 0. In this way I will construct this half one tree. Now in this example we want to we want to take on another example that is related to the half one code that is a E I C A H that will be observed in the previous table and I want to write down the encoding for input symbol S A C E and the output will become as for this encoding S is for the output A I will write 1, 1, 1 that is here 1, 1, 1 and for the C that is 1, 0 this is a 1, 0 and for the E it will become as a 0, 1. Therefore this total symbol for the encoding of the input S become as 1, 1, 1, 1, 0, 0, 1 this one of the simplest steps for the encoding. Now after that encoding we want to see half one decoding in this decoding read the compressed file and binary tree use binary tree to decode the files in that one follow the path from root to the left. Now I will take an example of for the half one decoding one is now I want to decode we decode this symbols that is 1, 1, 1, 1, 0, 0, 1 and this is a what tree now half one decoding is done with the help of this tree and this is a decoding steps. Now if you observe here now see one by one now the first symbol it will come one now according to the algorithm we want to go from bottom to the top therefore the first symbol is what one here one means what it will goes to the here one at the left of set again after that one I will write the one and again it will goes to the this will one this blue line indicates one and again I will go for the one that will indicates again that is a blue line that is one and after that one I will get the core a means what for this triple one I will get the core a again go for the next core that is one if you go from again it will goes from bottom to the top again one will goes to the this one one and after that one it will goes to the zero that is it will goes to the zero and after that one we get the symbol that is a C again that is a C symbol again I want to go from this zero again for this next code I will go from bottom to the top that is a next code is zero that will go to the right hand side that will indicated by this line this is a zero after that one we will go for one that is a one is a code for which we want to decode and it will go for one that is this one and we get the symbol E means what for the decoding purposes if you provide this code and this binary T from this one binary tree and this code we can decode and we get the data as S that is a C E now from this decoding and encoding we can easily short out the what is the properties of Huffman coding now before the understanding of what is we properties we can get it from we can understand easily from this example so we want to consider first example now from that one we want to see Huffman code properties now first here is a first properties prefects code now what is in the happening in the prefects code is no code is a prefects of another code now for example for the Huffman symbol the I here I will get the 00 and after that one for the X I will get here 001 and it is a not legal prefects code now this can stop as soon as complete the code found this will be stopped this Huffman code decoding part will be the stop when we receive the code for particular numbers then after that one we want to stop there now no need for end of code marker here no need of require of the marker here after the completion of this data whenever I get the symbol then we have to stop there therefore here no need end of code marker this is a very use important properties for the Huffman code now references for this topic are thank you