|
|
|
Week 4, 9/18
Prelab Exercises
- Complete the problems from Analysis in-class problems. Bring
your answers with you to lab.
- Review the
Comparable interface and read p.434-436 in Sedgewick & Wayne
- Review section 4.1 in Sedgewick & Wayne
Lab Exercises
- Snarf the classwork/04_ThreeSum project. ThreeSum.
- 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.
- 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?
- What is the big-Oh of that expression?
- Add a method,
count4 that counts the number of 4-tuples
that sum to zero. Give the big-Oh of your count4 method.
- 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.
- 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.
|