ICS 160E / ECE 144 - Algorithms Homework 4, 25 Points
Due: Friday, May 2, 2003

  1. 5 points. Problem R-3.1 from Goodrich-Tamassia.
  2. 5 points. Problem R-3.18 from Goodrich-Tamassia.
  3. 5 points. Problem C-3.19 from Goodrich-Tamassia.
  4. 5 points. Problem C-3.26 from Goodrich-Tamassia.
  5. 5 points. Write a Java function, hasDuplicates(Integer[] a), that uses the java.util.HashMap class to determine whether or not a given array of Integer objects contains two integers of the same value. Your algorithm should run in time roughly proportional to the size of the input array, a. Turn in a listing of your program and its output for the following arrays: Rule: This problem must be done independently. You cannot work with someone else on problem 5!
    Hint: study the class java.util.HashMap.
    You may also wish to look at the class java.lang.Integer.