Quiz 2a

Wed Feb 8

You have up to 20 minutes. You may use a standard calculator if necessary, but no text book or notes.

  1. +5 Convert the following 6-bit signed two’s complement binary numbers into base ten.

    1. 110100 -12 (= -32 + 16 + 4)
    2. 001011  11 (= 8 + 2 + 1)
    3. 110010 -14 (= -32 + 16 + 2)
    4. 101101 -19 (= -32 + 8 + 4 + 1)
  1. +5 Below is a tree representing a variable-width encoding of 9 letters. Use it to:

    • decode the bits 10111101110011101 into a word: FIGHT
    • encode the word FELT as bits: 1011101000001
  1. +5 If an image uses 12 bits for each pixel, what is the maximum number of distinct colors it can contain?

    \(2^{12} = 4096\) colors

  1. +5 Draw a tree representing a variable-width encoding of the four letters A, L, N, and T. Use it to encode the word ATLANTA. The fixed-width tree (below) uses exactly 2 bits per character, so encoding ATLANTA requires 14 bits. How many bits does your tree need to encode ATLANTA?

    A fixed-width encoding of four letters.

    A fixed-width encoding of four letters.

    Here is one possible solution. In this tree, L and N are extended to 3 bits each, so that A can be just 1 bit. We can then encode ATLANTA as 13 bits.