 Hello everyone, I am Dr. Asha Thalange and today we are here to learn Huffman coding technique. At the end of this session, students will be able to learn how to encode the messages of the transmitter using Huffman coding technique. These are the contents we will be covering. Huffman coding technique is another type of source coding method which is used for data compression applications. It generates variable length code and gives the lowest possible value of average length of code that is L bar for a given value of m that is the number of symbols used for coding. It also provides maximum efficiency as it has lower L bar and minimum redundancy. It is known as minimum redundancy code or optimum code. Now let us see the steps used for Huffman coding method. First step, arrange the given messages in the decreasing order of probabilities. Group the least probable m messages and assign them the symbols used for coding. Add the probabilities of the grouped messages and place them as high as possible and rearrange them in the decreasing order again. This process is known as reduction. Next step, repeat the steps 2 and 3 till only m or less than m probabilities remain in the final reduction. Obtain the code words for each message by tracing the probabilities from left to right in the direction of arrow till the end and writing the respective symbols 0 or 1 above the path by tracing them from right to left. Now let us consider one example to see the Huffman coding process. The problem statement is in a communication system the source transmits 5 different messages say x1 to x5 with the probabilities 0.3, 0.15, 0.25, 0.05 and 0.25 respectively. If the number of symbols used to code these messages is 2 then find the code word for each message and the coding efficiency by applying the Huffman coding. Now from this statement the given is the set of messages x1 to x5 and the probabilities and m is equal to 2 here. Now let us solve this step by step. The first step arrange the given messages in the decreasing order. These are the given messages and their probabilities and after arranging we get this. So here x1 to x5 are arranged in the decreasing order of probabilities. The second step is group the least probable m messages and assign the symbols used for coding. Now in this case m is equal to 2. So let us use the symbols 0 and 1. Also we need to group the least two messages having the lower probabilities. So 0.15 and 0.05 are the two probabilities which are lower compared to others. So these two are grouped and the symbols 0 and 1 is assigned to this as shown. Now the third step is add the probabilities of the grouped messages and place them as high as possible and rearrange them in the decreasing order again. So this process is known as reduction. Now the sum of the probabilities of these two is 0.2. Thus compared to all others it is having a lower value. So it is placed at the lower position. So these are the probabilities which are obtained after first reduction where the 0.2 is placed at the lower position. Now the next step is to repeat the steps 2 and 3 till only two probabilities remain as m is equal to 2 here. So we again group the least two probabilities assign the values. Now the sum of these two is 0.45 which is greater than the higher probability 0.3. Thus it is placed at the top position and the remaining probabilities are now shifted. So this is the values that we are getting after second reduction. Now if you see again the number of probabilities in this reduction is still greater than 2. So we have to keep on repeating this step till we get two probabilities in the reduction. So we again group the lower two probabilities assign the symbols. Now the sum of these two probabilities is 0.55 which is greater than 0.45. Thus 0.55 is again placed at the top position and 0.45 is now shifted. Thus we see that now in this reduction after this reduction only two probabilities remain. Now we stop the reduction. Finally we assign the symbols to these two probabilities. Now once the reduction is over the next step is to find the code words for each messages. So obtain the code words for each message by tracing the probabilities from left to right in the direction of the arrow till the end and writing the respective symbols 0 or 1 above the path by tracing them from right to left. Now let us find the code word for the message X1. So we will be tracing the probabilities from left to right. So this is how we are tracing now the arrow is pointing to the lower side. So change the path as per the direction of the arrow. Now again further the arrow from the group is again pointing to 0.55. So again we change the direction to follow the direction of the arrow. So this is how the final path is obtained. Now once the path is obtained you have to find the code word by tracing the path from right to left. So we have to trace the symbols on this path. So these are the symbols. So from right to left the first symbol is 0, second symbol is 0. No more symbols further thus the code word for X1 is 0 and 0. Let us now find the code word for X3. Similarly following the probabilities and following the direction of the arrow this is how the path moves. Again tracing the values or tracing the symbols on the path we get first 0, 1 and no more symbols further thus the symbol or the code word for X3 is 0, 1. Similarly we will get the code words for message X5. So this is the path no more symbols further so code word for X5 is 1, 0. Similarly code word for X2 is obtained by tracing the path so symbols 1, 1, 0. So code word for X2 is 1, 1, 0. Similarly for X4 the path is as shown so once the path is there the code word is obtained by tracing the symbols 1, 1 and 1 thus X4 code word is 1, 1. Thus now for all the messages we have got the code and the length of code is as shown. Now let us find the average length of the code word for each message by using this formula of L bar. Expanding the equation and substituting the values we get L bar to be 2.2 letters per message. Further entropy is calculated by using the formula. Expanding the equation substituting the values its value comes to be 2.15 bits per message. Now pause this video and recall what is the relationship between the average length of the code word and the efficiency of the system. Yes they are inversely proportional to each other that is less is the average length of the code more is the efficiency. So let us calculate the efficiency by using the formula so substituting the values we get efficiency to be 97.7 percent. Thus we see how Huffman coding method is used to find out the code word and the efficiency of the system. Also Huffman coding method is more efficient than Shannon Fano coding method. If you consider a system and find the efficiency of a system by using Huffman coding definitely it is more compared to the efficiency obtained by using Shannon Fano coding method for the same value of m. This is the reference used thank you.