A text is made up of the characters A, B, C, D, E each occurring with the probability 0.08, 0.40, 0.25, 0.15 and 0.12 respectively. The optimal coding technique will have the average length of:
2.15
The question asks about the average length of an optimal coding technique for a given set of characters and their probabilities. An optimal coding technique aims to minimize the average code length required to represent the characters, based on their frequencies or probabilities. One of the most well-known methods for achieving optimal prefix coding is Huffman coding.
Huffman coding is an algorithm used for lossless data compression. It builds a variable-length prefix code table based on the estimated probability of occurrence for each source symbol. The key idea is to assign shorter codes to more frequent symbols and longer codes to less frequent symbols, resulting in the minimum possible average code length for that set of probabilities.
Given the characters and their probabilities:
To find the optimal coding using Huffman algorithm, we follow these steps:
The generated Huffman codes and their lengths are:
| Character | Probability | Huffman Code | Code Length (\(L_i\)) |
|---|---|---|---|
| A | 0.08 | 0110 | 4 |
| B | 0.40 | 1 | 1 |
| C | 0.25 | 00 | 2 |
| D | 0.15 | 010 | 3 |
| E | 0.12 | 0111 | 4 |
The average length of the code is calculated by summing the product of each character's probability (\(p_i\)) and its corresponding code length (\(L_i\)). The formula is:
\[ Average\ Length = \sum_{i=1}^{n} p_i \times L_i \]
Using the probabilities and code lengths from the table:
Average Length = (0.08 \times 4) + (0.40 \times 1) + (0.25 \times 2) + (0.15 \times 3) + (0.12 \times 4)
Average Length = 0.32 + 0.40 + 0.50 + 0.45 + 0.48
Average Length = 2.15
The calculated average length for this optimal coding technique is 2.15.
| Concept | Description |
|---|---|
| Optimal Coding | A method that minimizes the average code length for a set of symbols based on their probabilities. |
| Huffman Coding | A greedy algorithm for optimal prefix coding. Assigns variable-length codes. |
| Prefix Code | No code is a prefix of another code. This allows unambiguous decoding. |
| Average Length | Expected code length, calculated as the sum of (probability * code length) for all symbols. |
| Data Compression | Reducing the amount of data needed to represent information. Huffman coding is lossless compression. |
The theoretical minimum average code length for a source is given by its entropy (\(H\)). Entropy is a measure of the uncertainty or randomness in the source. For a discrete source with probabilities \(p_1, p_2, \dots, p_n\), the entropy is calculated as:
\[ H = -\sum_{i=1}^{n} p_i \log_2(p_i) \]
Let's calculate the entropy for the given probabilities:
Entropy \(H \approx -(-0.291 - 0.529 - 0.500 - 0.411 - 0.367) = -(-2.098) = 2.098\) bits per character.
The average length of the Huffman code (2.15 bits) is very close to the entropy (2.098 bits), which demonstrates the efficiency of Huffman coding as an optimal coding technique. Huffman coding is guaranteed to achieve an average length within 1 bit of the entropy.
Match List-I with List-II:
List-I | List-II |
(a) Greedy best-first | (i) Minimal cost (p)+h(p) |
(b) Lowest cost-first | (ii) Minimal h(p) |
(c) A* algorithm | (iii) Minimal cost (p) |
Choose the correct option from those given below:
Which among the following statement(s) is(are) FALSE?
A. Greedy best‐first search is not optimal but is often efficient.
B. A* is complete and optimal provided h(n) is admissible or consistent.
C. Recursive best‐first search is efficient in terms of time complexity but poor in terms of space complexity.
D. h(n) = 0 is an admissible heuristic for the 8‐puzzle.
Suppose there are six files F1, F2, F3, F4, F5, F6 with corresponding sizes 150 KB, 225 KB, 75 KB, 60 KB, 275 KB and 65 KB respectively. The files are to be stored on a sequential device in such a way that optimizes access time. In what order should the files be stored?
A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09 and 0.24 respectively. The optimal Huffman coding technique will have the average length of :
If b is the branching factor and m is the maximum depth of the search tree, what is the space complexity of greedy search ?