Deign Shannon Fano Code for the following source code and calculate the length, entropy and efficiency of this code.
Question
Design Shannon Fano Code for the following source code and calculate the length, entropy and efficiency of this code.
Solution
1. Break Down the Problem
To solve this problem, we will follow these steps:
- Determine the probability of each symbol in the source code.
- Construct the Shannon-Fano code based on the probabilities.
- Calculate the length of the code.
- Determine the entropy of the source.
- Calculate the efficiency of the code.
2. Relevant Concepts
- Entropy (H): Defined as
where is the probability of the symbol.
- Code Length (L): The total number of bits assigned to each symbol.
- Efficiency (η): Defined as
3. Analysis and Detail
Assuming the source symbols and their probabilities are given as follows (as an example):
Symbol | Probability |
---|---|
A | 0.4 |
B | 0.3 |
C | 0.2 |
D | 0.1 |
Step 1: Construct Shannon-Fano Code
- List symbols in descending order of probabilities.
- Split the list into two parts with approximately equal probabilities.
- Assign '0' to the first part and '1' to the second part, then repeat recursively until all symbols are assigned codes.
Based on the probabilities given:
- Split between A (0.4) and B (0.3) + C (0.2) + D (0.1).
- Assign codes:
- A: 0
- B: 10
- C: 11
- D: 110
Step 2: Calculate Length of the Code
- Length of A: 1 bit
- Length of B: 2 bits
- Length of C: 2 bits
- Length of D: 3 bits
Step 3: Calculate the Entropy
Calculating each term:
Thus,
Step 4: Calculate Efficiency
4. Verify and Summarize
The values calculated here need to be checked against proper entropy calculations. The efficiency suggests that there seems to be some redundancy in the coding.
Final Answer
- Code Length (L): bits
- Entropy (H): bits/symbol
- Efficiency (η): or
Please replace the probabilities and symbols with your specific data to compute the corresponding results.
Similar Questions
Design Shannon Fano algorithm and Hoffman algorithm for your set of symbols. (show all the details).
huffmann codes areSelect one:a. uniquely decodableb. lossless source coding techniquec. all of themd. variable length codes
using hexadecimal notation write the ebcidic coding for the following. output, program , octal, byte
Apply Huffman - Coding procedure for M-2.And find the coding efficiency.Given: [X]= [xl x2 x3 x4 x5 x6 x7 x8][P}-[0.1,0.25,0.15,0.05,0.15,0.1,0.05,0.15]
The code where all successive numbers differ from their preceding number by single bit is *(A) Binary code.(B) BCD.(C) Excess – 3.(D) Gray
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.