ICS 160E / ECE 144 - Algorithms Homework 5, 25 Points
Due: Friday, May 9, 2002

  1. 5 points. Problem R-4.11 from Goodrich-Tamassia.
  2. 5 points. Problem C-4.10 from Goodrich-Tamassia.
  3. 5 points. Problem C-4.12 from Goodrich-Tamassia.
  4. 5 points. Problem C-4.13 from Goodrich-Tamassia.
  5. 5 points. Write a Java function, areSameSet(A,B), which takes two Object arrays, A and B, as input, and returns true if and only if those two arrays contain the same set of elements, ignoring duplicates. That is, areSameSet({1, 5, 3, 5, 7}, {7, 3, 5, 1, 1, 3}) and areSameSet({1, 6, 3, 5, 7}, {7, 3, 5, 1, 6, 3}) are true. But areSameSet({1, 6, 3, 5, 7}, {7, 3, 5, 1, 6, 9}) and areSameSet({1, 7, 3, 5, 2}, {7, 3, 5, 1, 6, 9}) are false. Please turn in a listing of your program and its output on the following arrays:
      • A = {"Alice", "Bob", "Cindy", "David", "Ed"}
      • B = {"Cindy", "Alice", "Doug", "Bob", "Ed"}
      • A = {"Alice", "Bob", "Cindy", "David", "Ed"}
      • B = {"Cindy", "Alice", "David", "Bob", "Ed"}
      • A = {8, 4, 2, 6, 2, 0, 10, 4}
      • B = {6, 2, 10, 2, 4, 8, 6, 2, 0}
      • A = {6, 4, 2, 6, 2, 0, 10, 4}
      • B = {6, 2, 10, 2, 4, 8, 6, 2, 0}

    Rule: This problem must be done independently. You cannot work with someone else on problem 5!
    Hint: study the class java.util.Arrays
    You may also wish to look at the classes java.lang.Integer and java.lang.String.