Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you run a company with two offices, one in Washington, D . C . and the other in San Francisco, Claifornia. You always spend

Suppose you run a company with two offices, one in Washington, D.C. and the other in San Francisco,
Claifornia. You always spend the whle week in one location, but each weekend, you decide whether
to fly to the other office. In week i, you can make Wi dollars if you are in Washington, and Ci
dollars if you are in Calfiornia. Each flight from one office to the other costs 1000. Suppose you are
initially in D.C., and you are given the lists of potential profits for each location: W1,W2,dots,Wn and
C1,C2,dots,Cn. Additionally, you are given Lfin{C,W}, your final location which is the location that
you must be in after the nth week. This means if you spent the nth week in California, and Lf=W
you must spend a final $1000 to fly back at the end of the nth week. In this problem, you will come
up with an algorithm to maximize your profit.
(a) A greedy algorithm would look at how much money you would make in each week, and work in
the place that will earn the most that week (after travel costs). Give a counter example to show
why this greedy algorithm is not always optimal. (Your example should have n3, otherwise a
later part of this problem will be more challenging.)
(b) Create a dynamic programming algorithm to solve this problem. I will guide you through the
steps
i. Identify the likely subproblems and recurrence objects. (Ilint: you need two sequences of
subproblems, depending on whether you have to end up in DC or California)
ii. Determine the relevant final options for the recurrence object and write a recurrence relation
for your recurrence object for each option. Also determine base case(s). Briefly explain.
iii. Turn your recurrence relation for your recurrence object into a recurrence relation for the
objective function value.
iv. Fill in pscudocode for an algorithm to determine the optimal schedule.
(c) What is the runtime of your algorithm?
(d) Apply your algorithm to your example from part (b) and show that it outputs the correct
schedule.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions