next up previous

CSE 2320 Section 501/571 Fall 1999

Homework 4

Due: November 9, 1999, in class (November 10, 1999, 5:00pm for -10%)

Consider the problem of using rental cars to drive along a highway from one location to another. There are n rental car agencies along the highway. At any of the agencies you can rent a car to be returned at any other agency down the road. You cannot backtrack. For each possible departure point i and each possible arrival point j the cost of a rental from i to j is known. However, the cost of renting from i to j may be higher than the total cost of a series of shorter rentals. In this case you can return the first car at some agency k between i and j and continue your trip in a second car. There is no extra charge for changing cars in this way.

Let c(i,j) be the optimal cost of driving from agency i to agency j. Assuming the optimal trip from i to j consists of trips from i to k and from k to j, give an expression for c(i,j) in terms of c(i,k) and c(k,j).

Prove that the driving problem exhibits optimal substructure.

Define a recursive solution for computing c(i,j) and write pseudocode for a divide-and-conquer algorithm implementing your solution.

Give a recurrence T(n) for the running time of your recursive solution in part c, where n=j-i+1, and show that $T(n) = \Omega(2^n)$.

Demonstrate that the recursive solution has overlapping subproblems and compute the number of unique subproblems.

Write pseudocode for a O(n3) bottom-up, dynamic programming solution to the driving problem. Justify the O(n3) running time of your solution. Input to your procedure will be i, j and the cost matrix, and the output will be the optimal-cost sequence of stops along the way.

Consider a greedy algorithm for the driving problem where the greedy choice is to choose the lowest cost single car trip from your current location (originally i) to some other location k along the way to j, and then continue with the same greedy choice from k. Again, no backtracking is allowed. Give a counterexample showing that this greedy choice does not satisfy the greedy choice property, and explain why.

Problem 17-1a, page 353.

next up previous