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

Saint Louis University

Computer Science 140
Introduction to Computer Science

Michael Goldwasser

Spring 2008

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 Tuesday, 12 February 2008


Problems to be Submitted (20 points)

  1. (6 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. (6 points)

    Consider the following Huffman code.
    codecharacter
    00A
    11E
    010T
    0110C
    0111L
    1000S
    1011R
    10010O
    10011I
    101000N
    101001F
    101010H
    101011D

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

    1. 1000110110101111010
    2. 1010111101101001010101111
    3. 01101001010100001011101000010

  3. (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 the minimal fixed-length code possible for this alphabet set, 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 for problem B of this homework.
    3. Based on your Huffman code, how many overall bits would be used to represent all 39 characters in the message?
    4. What compression ratio was achieved over the fixed-length code in part a?

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)

Let's say that you are taking pictures at a resolution of 1024x768 pixels and that it stores 24-bit color for each individual pixel. Assuming that pictures are stored in raw form (that is, not using any compressed file format), please answer the following questions.

  1. Calculate how many bits of information would be used to represent a single such picture. 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. Approximately how many pictures could be stored on a 512MB USB flash drive?


CSCI 140, Spring 2008
Michael Goldwasser © 2008
goldwamh at our university domain

Last modified: Wednesday, 19 September 2007
Assignments | Class Photo | Course Home | Schedule & Lecture Notes | Submit | Tutoring Hours