Information Theory and Coding Basics
A binary prefix code is to be built by assigning codewords of the following lengths (numbers of bits) to the four symbols A to D. Which of the following sets of code lengths makes this possible?
- AA: 1, B: 2, C: 3, D: 3
- BA: 1, B: 2, C: 2, D: 3
- CA: 1, B: 1, C: 2, D: 3
Show answer and explanation
Answer: A. A: 1, B: 2, C: 3, D: 3
A prefix code with code lengths l₁, l₂, … can be built exactly when the Kraft inequality Σ 2^(−lᵢ) ≤ 1 holds. For 1, 2, 3, 3 the sum is 1/2 + 1/4 + 1/8 + 1/8 = 1, so it can be built, for example as 0, 10, 110, 111. For 1, 2, 2, 3 the sum is 1/2 + 1/4 + 1/4 + 1/8 = 9/8, and for 1, 1, 2, 3 it is 1/2 + 1/2 + 1/4 + 1/8 = 11/8; both exceed 1, so neither can be built.
- A. Correct. The sum of 2^(−l) is exactly 1, and the code can be built as 0, 10, 110, 111.
- B. The sum is 9/8, which exceeds 1. The length-1 word 0 and the length-2 words 10 and 11 use up every way a bit string can begin, leaving no room for a length-3 codeword.
- C. The sum is 11/8, which exceeds 1. If both 0 and 1 are used as length-1 codewords, every other codeword must begin with one of them.
Continue: 9 more Information Theory and Coding Basics questions