CSE 373, Autumn 2004: Assignment 3

Objectives

The objectives of this assignment are to help you become fluent with three mathematical techniques for studying data structures and algorithms: (a) functional description of abstract data types, (b) proofs using mathematical induction, and (c) comparing growth rates of functions using big O notation and its variations.

When and How

Turn in this assignment on paper (hardcopy) at the beginning of class on Friday, October 22. This assignment must be done individually (not in partnerships or groups). If you are not sure what that means, consult the Department of Computer Science and Engineering academic misconduct policy

The Exercises

This page is best viewed using the Mozilla Firefox browser. In particular, the table in Exercise 5 formats better with Firefox than with I.E.
  1. (10 points) Consider the following ADT for a one-dimensional array of strings.
    Data:
     a function whose domain is the set {0, 1, ..., n-1}
     and whose range is the set of strings (over the ASCII character set).
    
    Operations:
     STORE -- puts a string in a particular array location.
     ACCESS -- returns a string from a particular array location.
    

    (a) Let fs be a function representing the STORE operation. Identify the domain and range of fs. Give a formula that shows how fs maps an element of its domain to the corresponding element of its range.
    (b) Let fa be a function representing the ACCESS operation. Identify the domain and range of fa. Give a formula that shows how fa maps an element of its domain to the corresponding element of its range.
  2. (10 points) Prove by induction that for all nonnegative integers n
    6(12) + 6(22) + ... + 6(n2) = n (n+1)(2n+1)
  3. (10 points) Prove by induction that for all nonnegative integers n
    4(13) + 4(23) + ... + 4(n3) = n2 (n+1)2
  4. (10 points) Prove by induction that the INTERLEAVE algorithm (the one implemented in the sample solution to Assignment 1 below) correctly interleaves the elements of two lists for a pair of equal-length lists of length 0 or more.
    static Node interleave(Node listA, Node listB) {
      if (listA == null) return listB;
      if (listB == null) return listA;
      return addToFront(listA.data, 
                         (addToFront(listB.data,
                           interleave(listA.next, listB.next))));
    }
    
  5. (a) (20 points; -2 for each incorrect entry) Fill in the following table Each entry should be either big O, Ω (big omega), Θ (big theta), or "incomparable." Since row 1 is already filled in for you, there should not be any ambiguity in what you need to do here.
     
    f(n) = 5 f(n) = 10 log2 n f(n) = sqrt n f(n) = n / 100 f(n) = 50 n f(n) = n log2 n f(n) = 2n2 f(n) = 100n2 f(n) = 1.01n f(n) = n!
    f(n) = 5 ΘOOOOOOOOO
    f(n) = 10 log2 n           
    f(n) = sqrt n           
    f(n) = n / 100           
    f(n) = 50 n           
    f(n) = n log2 n           
    f(n) = 2n2           
    f(n) = 100n2           
    f(n) = 1.01n           
    f(n) = n!           

     

    (b) (5 points) Justify your entry for the comparison between n log2 n and 2n2 (using the justification approach shown in Example 3.6 of Goodrich and Tamassia 3rd edition on page 118).
    (c) (5 points) Justify your entry for the comparison between 2n2 and 100n2.
In exercises 2, 3, and 4 (the proofs by induction), the TAs have proposed 2 points for the basis, 2 points for stating the induction hypothesis, 5 points for completing the induction step, and 1 point for summarizing and organizing all information into a complete proof.
There are 70 points possible for the whole assignment.
 

 
(version of 14 Oct. 2004, with a correction to question 5 on 20 Oct., S. Tanimoto)