Information Theory and Coding Basics
Which of the following sets of codewords assigned to four symbols is a prefix code (a code in which no codeword is the beginning of another codeword)?
- A{0, 01, 011, 111}
- B{0, 10, 110, 111}
- C{00, 01, 1, 10}
Show answer and explanation
Answer: B. {0, 10, 110, 111}
In a prefix code, a symbol is determined the moment its codeword has been read, so it can be decoded immediately without waiting for later bits (an instantaneous code). In {0, 10, 110, 111}, no codeword is the beginning of another. In {0, 01, 011, 111}, 0 is the beginning of 01 and 011, and in {00, 01, 1, 10}, 1 is the beginning of 10.
- A. 0 is the beginning of 01 and 011, and 01 is the beginning of 011, so it is not a prefix code.
- B. Correct. No codeword is the beginning of another codeword.
- C. 1 is the beginning of 10, so it is not a prefix code. On receiving a 1, it is impossible to tell whether to cut there.
Continue: 9 more Information Theory and Coding Basics questions