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

  1. 5 points. Problem R-5.9 from Goodrich-Tamassia.
  2. 5 points. Problem R-5.12 from Goodrich-Tamassia.
  3. 5 points. Problem C-5.1 from Goodrich-Tamassia.
  4. 5 points. Problem C-5.5 from Goodrich-Tamassia.
  5. 5 points. Design a Java function, matrixChain(D), which takes an array, D, of n+1 positive int elements that are the ordered listing of dimmensions of an instance to the matrix chain product problem, as specified in Section 5.3.1 (so that D[i] is the same as di). Your program should output a string that corresponds to an optimal parenthesization of the arrays A0, A1, ... . For example,
    matrixChain({2, 10, 50, 20}) = "((A0*A1)*A2)".
    Please turn in a listing of your program and its output on the following arrays:
    1. D = {2, 10, 5, 100, 4}
    2. D = {5, 10, 5, 10, 5}
    3. D = {10, 100, 1000, 10, 1000, 10, 1, 1000}
    4. D = {50, 2, 50}
    5. D = {10, 20}

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