 Hello everyone. Welcome to this session. I am Dr. Asha Tharangi and today we are going to learn Huffman coding technique for non-binary systems. At the end of the sessions, students will be able to encode the messages using Huffman coding technique for non-binary systems. These are the contents we will be covering in this session. Non-binary system is a system where the number of symbols used to code is greater than 2, that is, m is greater than 2. For non-binary systems, the grouping is to be handled in a different way sometimes for the Huffman coding technique. Let us see how. Let us see this by using one of the examples. In a communication system, the source transmits 8 different messages x1 to x8 with the probabilities given. Considering m equal to 4, find the average code word by applying Huffman coding method and Shannon-Fanning coding method. Now, from this, the given is 8 messages x1 to x8 with the respective probabilities and m is equal to 4. Let us solve this by first using Huffman coding method. The first step is to arrange the messages in the decreasing order of this probabilities. These are the given messages with their probabilities and after arranging, this is the sequence that we get. Now, the second step is to group the m messages, lower probability m messages and assign them the symbols used for coding. In this case, m is equal to 4. So, let us use the symbols 0, 1, 2 and 3. Now, the least 4 terms with lower probabilities are grouped and the symbols are assigned as shown. So, the next step is to add the probabilities of these terms and place it as high as possible and rearrange them in the decreasing order again. So, the group of these 4 terms comes to be 0.3, which is greater than the higher probability 0.2 here. So, it is placed at the top position and all others are shifted further as shown. So, these are the terms obtained after first reduction. Now, if you see the number of terms after first reduction is still greater than 4. So, we need to continue this process till we get just 4 terms or less than 4 terms in the last reduction. So, again the 4 terms are grouped, symbols are assigned as shown. Now, the sum of probabilities of these terms comes to be 0.7. As it is greater than 0.3, it is placed at the top position and then 0.3 is shifted next to it. Now, you can see after the second reduction, only two terms remains. No further reduction is required. So, the symbols are assigned to it. Now, once the reduction procedure is over, we need to now find out the code word for all the messages. So, in order to obtain the code word, the probabilities are traced from left to right and the symbols are traced from right to left on that path. So, let us find the code word for X1. So, tracing the path of probabilities, this is how it moves following the arrow. So, this is the path traced for X1 from left to right. Now, the symbols on the path from right to left is 0, 0 and no further symbols. So, the code word for X1 is 0, 0. Similarly, the code words for all messages are obtained. This table shows the code word and the length of each code for each message. Now, all the code words are of size 2. Therefore, the average length of the code word is two letters per message. Before moving ahead, pause this video and recall. Among the two source coding techniques, Shannon Fanon and Huffman coding technique, which one is more efficient? Yes, the answer is Huffman coding technique. Now, let us solve the same problem by using Shannon Fanon coding method. Now, arrange the given messages again in the decreasing order of their probabilities. So, this is the sequence that we obtain. In Shannon Fanon coding method, the next step is to divide the probabilities into m equi-probable message subsets. Here m is equal to 4. So, the first possible partition is as shown. Now, as m is 4, let us use force involves 0, 1, 2 and 3. 0 is assigned to the messages in the first subset, 1 is assigned to the second subset, 2 is assigned to the messages in the third subset and 3 is assigned to all the messages in the fourth subset. Further, subset 1 and 2 consist of only one messages or one probability. So, no further partition is possible here. Considering this third subset, now it consists of two probabilities. So, possible partition is only here and again we assign the symbols 0 and 1 as shown. In the last subset, it consists of four probabilities. So, dividing it into four parts, this is the possible partition and once we partition, we assign the symbols as shown. Now, the code words for all the messages is just obtained by tracing the symbols from left to right. Now, this table shows the code words obtained for all the messages using Shannon Fano coding method and the length of each code word. Average length of code word for each message is then calculated by using the formula L bar. Substituting the values, we get L bar is equal to 1.6 letters per message. Now, you can see here by Huffman coding, the average length of code word comes to be two letters per message and by using Shannon Fano coding method, the average length comes to be 1.6 letters per message. Now, if you see here, Shannon Fano coding method is giving more efficient result, whereas in general Huffman coding is a more efficient one. So, what is the problem with this? Let us see. Now, if you see this in Huffman coding, the number of terms obtained in the last reduction is equal to 2. This is a problem. Now, let us solve the same problem using this Huffman coding such that the number of terms appearing in the last reduction is equal to now 4 instead of 2. In order to do this, we need to first combine two terms in the first reduction. Let us solve this again by doing this way. Now, the messages are again arranged in the decreasing order of their probabilities. Now, let us first group the last two terms. Assigning the symbols, we now get its value sum of the two probabilities equal to 0.1, which is placed at the lower position after the second reduction in order to maintain the decreasing order of their probabilities. Now, after this first reduction, again the last four terms are now combined and placed at a higher value as per their probabilities. Now, the sum of these probabilities is 0.45, which is greater than 0.2. So, it is placed at the top position and all other remaining probabilities are shifted below that. So, now you can see at the last reduction, we get four terms here. Finally, assigning the symbols to those four terms. Now, let us find the code word for this. Now, the code words obtained for X1 to X8 after the second Huffman coding and the length of each code word is shown in this table. Now, let us find the average length of code word. Using this formula L bar and substituting the values. Now, the average length of code word comes to be 1.55 letters per message. Now, if you see this, this is better not just the previous Huffman coding, but also better than the Shannon Fanno coding method. Let us analyze why it has happened so. In the first Huffman coding, only two terms remains in the last reduction. Whereas, in the second Huffman coding, we reduce it such that four terms remain in the last reduction. Due to this, we see the length of code word for higher probability messages is greater compared to the length of code word for the higher probability messages compared to the second method. Even though the length of code word for the lower probability messages in the first method is lower than the length of code words for the lower probability messages in the second method. In spite of that, we are getting efficient average code word length. This is because the weight of the higher probability messages is higher than the lower probability messages. Due to this, the average length of code word in the first Huffman coding is greater compared to the second Huffman coding method. Thus, we can see that in order to get an efficient average length of code word by using a Huffman coding, we need to code it in such a way that or we need to reduce it in such a way that the number of terms that is appearing in the last reduction is equal to m. This is the reference that is used. Thank you.