UMBC CMSC441, Design & Analysis of Algorithms, Fall 1999, Section 0201

Homework Assignments 7-8

The following homework problems have been assigned for Section 0201 of CMSC441.

Homework 7, Due Wednesday October 27

  1. Problem 16-4, page 326.

  2. Exercise 17.2-4, page 337.

    Note: make sure that you also state and justify the running times of your algorithm.

  3. Consider the following modification to Exercise 17.2-4.

    In this problem, Professor Midas is not only given the location of each gas station along Interstate 80. He is also given the price per gallon of gas at each gas station. His new goal is to minimize the cost of gasoline for the trip rather than the number of stops.

    1. Show that the greedy algorithm for Exercise 17.2-4 does not work (i.e., give a counterexample).

    2. Give a dynamic programming solution to the problem, argue that your algorithm is correct, then state and justify the running time of your algorithm.

Homework 8, Due Wednesday November 3

  1. Exercise 16.3-5, page 319.

  2. Problem 17-1, page 353.

  3. Consider the following table for the operation * on the symbols a, b and c.

    * a b c
    a b b a
    b c b a
    c a c c

    According to this table, a * b = b and b * a = c. Note that * is neither commutative nor associative.

    Devise an algorithm which given a list of symbols x1, ..., xn such that each xi is in {a, b, c}, determines whether it is possible to parenthesize x1 * x2 * ... * xn in such a way that the resulting expression evaluates to a. If so, your algorithm should also produce such a parenthesization.

    For example, for b * b * b * b * a, your algorithm should return "yes" because ((b * (b * b)) * (b * a)) = a. Note that the solution does not have to be unique. For example, (b * (b * (b * (b * a)))) is also equal to a.

    Remember to argue that your algorithm is correct and to state and justify the running time of your algorithm. For full credit, your algorithm must be reasonably fast.


Maitreyee Pasad
Last modified: Wed Oct 13 13:04:33 EDT 1999
to Fall 1999 CMSC 441 Section Homepage