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)?

  1. A{0, 01, 011, 111}
  2. B{0, 10, 110, 111}
  3. 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.
Practice this topic Back to topic

Books on Information Theory and Coding Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Information Theory and Coding Basics questions

  1. A prefix code assigns the codewords A = 0, B = 10, C = 110 and D = 111 to the symbols A, B, C and D. Which of the following is the result of decoding the bit string 110100111 from the start?
  2. 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?
  3. A binary prefix code is being built, and the length-2 codewords 00 and 01 are already in use. Which of the following is the maximum number of length-3 codewords that can be added while keeping the prefix condition?
  4. A source emits the symbols A, B, C and D independently with probabilities 0.4, 0.3, 0.2 and 0.1, and it is encoded with a Huffman code. Which of the following is the average code length per symbol?
  5. A source emits the symbols A to E independently with probabilities 0.3, 0.25, 0.2, 0.15 and 0.1, and it is encoded with a Huffman code. The codewords may change depending on which of two equal probabilities is chosen first, but the average code length does not. Which of the following is the average code length per symbol?