Duke CS Logo CompSci 100e: Program Design & Analysis II
(Fall 2009)
Home
Course Information
Calendar
Resources
Assignments
APT problems
Lab
Lab 1 - 08/28
Lab 2 - 09/04
Lab 3 - 09/11
Lab 4 - 09/18
Lab 5 - 09/25
Lab 6 - 10/02
Lab 7 - 10/09
Lab 8 - 10/16
Lab 9 - 10/23
Lab 10 - 10/30
Lab 11 - 11/06
Lab 12 - 11/13
Lab 13 - 11/20
Lab 14 - 12/04
Help sessions
Discussion Forum
Blackboard
Oasis

Week 4, 9/18

Prelab Exercises

  1. Complete the problems from Analysis in-class problems. Bring your answers with you to lab.
  2. Review the Comparable interface and read p.434-436 in Sedgewick & Wayne
  3. Review section 4.1 in Sedgewick & Wayne

Lab Exercises

  1. Snarf the classwork/04_ThreeSum project. ThreeSum.
    1. Add code to read in a list of numbers from an input file and convert that list into an array of longs to pass into the count method.
    2. In terms of n, the number of elements in a, how many times is the conditional expression (a[i] + a[j] + a[k] == 0) executed in count?

      
      
      
    3. What is the big-Oh of that expression?
      
      
    4. Add a method, count4 that counts the number of 4-tuples that sum to zero. Give the big-Oh of your count4 method.
      
      
  2. Complete the ClassScores APT. In the comments for your file, please give the big-Oh for your solution and justify your answer by giving the number of times each line of code is executed in terms of n, the array size.
  3. Extra: Complete the Dirsort APT

Submit

For this lab, submit ThreeSum.java, ClassScores.java, Dirsort.java, and a README with the answers to the analysis questions above under assignment name lab04.
Last updated Fri Dec 04 11:33:59 EST 2009