Design Shannon Fano algorithm and Hoffman algorithm for your set of symbols. (show all the details).
Question
Design Shannon Fano algorithm and Hoffman algorithm for your set of symbols. (show all the details).
Solution
Sure, let's start with the Shannon-Fano Algorithm:
-
First, we need to have a set of symbols with their corresponding frequencies or probabilities. Let's assume we have the following set of symbols: A, B, C, D, E with frequencies 15, 7, 6, 6, 5 respectively.
-
Sort the symbols according to their frequencies. The symbol with the highest frequency comes first.
-
Divide the set into two parts, where the total count of frequencies is approximately equal in both parts.
-
Assign '0' to the first part and '1' to the second part.
-
Repeat the process for each part until you get to individual symbols.
-
The Shannon-Fano code for a symbol is the string of binary digits you get by concatenating the '0's and '1's assigned from the top of the symbol set to the symbol.
Now, let's move on to the Huffman Algorithm:
-
Again, we start with the same set of symbols and their frequencies.
-
Create a node for each symbol and add them to the priority queue.
-
While there is more than one node in the queue:
- Remove the two nodes of highest priority (lowest probability) from the queue
- Create a new node with these two nodes as children and with probability equal to the sum of the two nodes' probabilities.
- Add the new node to the queue.
-
The remaining node is the root node and the Huffman tree is complete.
-
Traverse the constructed binary tree from the root to leaves. At each node, if we move to the left child, we append a '0' to the code. If we move to the right child, we append a '1' to the code. The Huffman code for a symbol is the string of binary digits you get when you reach the leaf node for the symbol.
Please note that both algorithms aim to minimize the average length of the codes, but Huffman's algorithm guarantees an optimal solution.
Similar Questions
Generate a set of 10 symbols, including how frequent each symbol will be used.
Deign Shannon Fano Code for the following source code and calculate the length, entropy and efficiency of this code.
Question A [10 marks in total]. Louise needs to send to Madhu sequences which consist of lettersT, E, B, L. Each letter is represented by a two-bit message, as follows:T= [0 0], E= [0 1], B= [1 0], L= [1 1].Since Louise and Madhu have to use a one-way, noisy channel, BSC(𝑝) with small 𝑝, Louise encodeseach message using the generator matrix𝐺 = [1 0 0 1 10 1 1 0 1]of a binary linear code 𝐶.A1 [2 marks] Represent the word LET as three two-bit messages, encode each message as describedabove and write down the resulting three codevectors of 𝐶.A2 [2 marks] Write down a standard array for 𝐶. (You do not need to explain your answer.)A3 [2 marks] Determine 𝑃corr(𝐶), the probability that a codevector of 𝐶 is sent over BSC(𝑝) andthe received vector is decoded correctly. (Briefly indicate what you have used to arrive at theanswer.)A4 [2 marks] Madhu received the following six vectors via the channel:[1 1 0 1 1] , [0 1 1 0 0] , [0 1 1 0 1] , [0 0 1 0 0] , [0 1 1 1 0] , [1 1 1 0 1]Determine the six-letter sequence which was most likely sent by Louise. For decoding, youmust use the standard array you constructed in part A2; you should indicate, e.g., by drawingarrows on the standard array, how you decode the received vectors. Your answer needs to besix letters, not vectors, which means that you need to unencode your answer.A5 [2 marks] Write down the weight enumerator 𝑊𝐶(𝑥, 𝑦) of 𝐶.
Question A [10 marks in total]. Louise needs to send to Madhu sequences which consist of lettersT, E, B, L. Each letter is represented by a two-bit message, as follows:T= [0 0], E= [0 1], B= [1 0], L= [1 1].Since Louise and Madhu have to use a one-way, noisy channel, BSC(𝑝) with small 𝑝, Louise encodeseach message using the generator matrix𝐺 = [1 0 0 1 10 1 1 0 1]of a binary linear code 𝐶.A1 [2 marks] Represent the word LET as three two-bit messages, encode each message as describedabove and write down the resulting three codevectors of 𝐶.
Question A [10 marks in total]. Louise needs to send to Madhu sequences which consist of lettersT, E, B, L. Each letter is represented by a two-bit message, as follows:T= [0 0], E= [0 1], B= [1 0], L= [1 1].Since Louise and Madhu have to use a one-way, noisy channel, BSC(𝑝) with small 𝑝, Louise encodeseach message using the generator matrix𝐺 = [1 0 0 1 10 1 1 0 1]of a binary linear code 𝐶.A1 [2 marks] Represent the word LET as three two-bit messages, encode each message as describedabove and write down the resulting three codevectors of 𝐶.A2 [2 marks] Write down a standard array for 𝐶.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.