Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

9. (6 pts) Suppose that you\'re running a lightweight consulting business. Your

ID: 3733270 • Letter: 9

Question



9. (6 pts) Suppose that you're running a lightweight consulting business. Your clients are distributed between the East Coast and West Coast, and this leads to the following question. Each month, you can either run your business from an office in New York (NY) or from an office in San Francisco (SF). In month i you'll incur an operating cost of N, if you run the business out of NY; you'll incur an operating cost of S, if you run the business out of SF. (it depends on the distribution of client demands for that month). However, if you run the business out of one city in month i, and then out of the other city in month i+1, then you incur a fixed moving cost of M to switch base offices. Given a sequence of n months, a plan is a sequence of n locations - each one equal to either NY or SF - such that the ith location indicates the city in which you will be based on the ith month. The cost of a plan is the sum of the operating costs for each of the n months, plus a moving cost of M for each time you switch cities. The plan can begin in either city.

Explanation / Answer

Solution:

(a) n = 3, M = 10

You can see that the above code will give NY, SF, NY - giving a cost of 5+5+5+10+10 = 35.

While the correct answer is NY,NY,NY - giving a cost of 5+10+5 = 20.

(b) n = 4, M = 10.

Optimum solution - NY , SF, NY, SF. (3 switches)

The reason for the above is that the difference in operating costs is so big that even after paying the moving cost every time, we arrive at a cheaper total cost.

(c)

# Current variable stores which city we are in currently.

if NY[1] < SF[1]

current = NY

else

current = SF

For i = 2 to n

if current == SF

if NY[i] + M < SF[i]

current = NY

Output "NY in Month i"

else

Output "SF in Month i"

else

if SF[i] + M < NY[i]

current = SF

Output "SF in Month i"

else

Output "NY in Month i"

Month 1 Month 2 Month 3 NY 5 10 5 SF 10 5 10