

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


a. Let F (i) be the estimated total profit of the optimal plan that considers only intersections 1 to i. Write down the recurrence function for computing F (i). Recurrence:
F (i) = max
{ F (i − 1) F (i − 2) + p(i)
Initially F (1) = p(1) and F (2) = max(p(1), p(2)).
b. Show how to use the recurrence function to find the optimal plan given the estimated profits below.
intersection (i) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 profit (p(i)) (× $100k) 6 3 1 4 5 6 3 1 3 2 4 4 5 5 1
Dynamic programming table:
i 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 p(i) 6 3 1 4 5 6 3 1 3 2 4 4 5 5 1 F (i) 6 6 7 10 12 16 16 17 19 19 23 23 28 28 29 The most profit, 29 × 100k = 2.9m, can be obtained by selecting intersections 1, 4, 6, 9, 11, 13, 15.
miles from gi. If we replace gk with gj , however, the solution is still valid since gj is now closer to the next selected gas station gl. Therefore, by replacing gk with gj , we will obtain a solution that is at least as good as the optimal solution. This means the strategy must be optimal.
a. Show the adjacency list representation of the graph below.
adj[1] = {3, 6} adj[2] = {3} adj[3] = {1, 2, 4} adj[4] = {3, 6} adj[5] = {6, 7} adj[6] = {1, 4, 5, 7} adj[7] = {5, 6}
b. Draw a graph that can be represented by the adjacency matrix below.
d a b f g e
c