Assignments | Class Photo | Course Home | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 115
Introduction to Computer Science
Michael Goldwasser

Fall 2004

Dept. of Math & Computer Science

Assignment 03

Data Representation and Compression

Contents:


Overview

Topic: Data Representation and Compression
Related Reading: Ch. 3.1, 3.3-3.6 and notes
Due: 8pm Monday, 20 September 2004


Internet Requirements

You may need an Internet connection for completing the assignment in order to access the lab software.


Practice Problems

Problems to be Submitted (20 points)

  1. (3 points)

    In the notes, we stated that CD quality music requires 44100 samples per second. The amplitude of the sound wave is recorded using 16 bits per channel. (Recorded in stereo, there are two separate channels). Based on this information, please answer the following:

    1. Calculate how many bits of information would be used to represent a 4 minute song, recorded in stereo. Express your answer using the most natural unit of magnitude (e.g., bytes, KB, MB, GB). Please explain the details of your calculations so that we can better understand your method in case of a wrong answer.

    2. Assume that a single compact disk, formatted for audio, holds up to 700MB of information. Approximately how many of those 4-minute songs will fit on the CD.

  2. (3 points)

    The following color patch was taken from a section of SLU's front web page.

    Use the Color Maker Applet to match this color as best possible. 

    Indicate your answer based on its 24-bit TrueColor RGB value. For example, page 78 of the book described purple as (157,95,82).

    Hint: SLU's color is not "pure" blue. To match it, you can either experiment with modifying the individual color components, or you may wish to set the color with the alternate controls for hue, saturation, and brightness.

  3. (3 points)

    Consider the Huffman encoding table given on page 89 of the text (associated with Exercise 57).

    Decode each of the following bit strings according to that code.

    1. 1000110110101111010
    2. 1010111101101001010101111
    3. 0110100101010000101110100010
      01101001010100001011101000010
      (Updated 9AM, 20 September due to error pointed out by student)

    You may use the Huffman Encoding applet if want, or use it to check. your work. If you do use the applet, be careful not to put a newline character at the end of your code.

  4. (8 points)

    Consider the text "PETER PIPER PICKED PICKLED PEPPER PECKS"  (a slight variation on the classic tongue-twister to simplify your problem).  It contains 39 characters, with the following frequencies:
    Letter Frequency
    P 9
    E 8
    blank 5
    C 3
    I 3
    K 3
    R 3
    D 2
    L 1
    S 1
    T 1

    1. If using a fixed-length code for this message, how many bits per character must be used, and thus how many overall bits would be used to represent all 39 characters of the message.

    2. Based on the method discussed in the lecture notes, generate a Huffman code for this set of frequencies (Note: this method was not discussed in the text). Your answer should be a table of codes, formatted similarly to the one given in the text for Exercise 57.

    3. Based on your Huffman code, how many overall bits would be used to represent all 39 characters in the message?  You can use the Huffman encoding applet to work this out or check your answer.  The applet is a bit finicky.  Be careful of two things:

      • Make sure you do not end the message text with a new-line.
      • Make the first character in each line of the code box be the character coded, including a blank space character on one line, then have at least one blank before the binary code; that makes two blanks at least for the line with the code for blank.
    4. What compression ratio was achieved over the fixed-length code in part a?  (Be careful if you are using the applet -- it compares to a fixed eight-bit code. Also, it indicates the compression percentage by the amount removed, not the amount left as we have defined it in class.)

  5. (3 points)

    At the end of Ch. 3 there are a series of "Thought Questions." Pick any one question from #3, #4, #5, #6 or #7 to answer. The length of your answer should be appropriate for the question, however I envision answers in the range of 1/2-page to 1-page.

Overall, please type your answers to all of the problems in a single document to be submitted electronically. Please see details about the submission process.


Extra Credit (2 points)

tba
CSA-115, Fall 2004
Michael Goldwasser
goldwamh at our university domain

Last modified: Monday, 20 September 2004
Assignments | Class Photo | Course Home | Schedule & Lecture Notes | Submit