Consulting business [00QN]
- October 27, 2026
The problems in this section all refer to the following scenario.
Scenario [00QO]
- October 27, 2026
You are running a consulting business, with clients on both east and west coasts. Each month, you can run your business from an office in either New York or San Fransisco. In month i, you will incur an operating cost of N_i if you run the business out of New York; you will incur an operating cost of S_i if you run the business out of San Fransisco (the costs can change each month depending on the distribution of client demands).
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 cities.
Given a sequence of n months, a plan is a sequence of n locations—each one equal to either \mathsf {NY} or \mathsf {SF}—such that the ith location indicates the city in which you will be based in 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.
Given a value for the moving cost M, and sequences of operating costs N_1, \dots , N_n and S_1, \dots , S_n, the problem is to find a plan with minimum total cost.
[DP1] Greedy failure (1 pt) [00QP]
- October 27, 2026
Show that the following greedy algorithm does not correctly solve this problem, by describing inputs for which it does not return the correct answer.
In your example, be sure to explain what the correct answer is and also what the above algorithm finds.
[DP2] Consulting recurrence (1 pt) [00QQ]
- October 27, 2026
Let C(i,c) denote the minimum cost possible if you operate your business for only months 1 through i and end in city c. For example, C(3,\mathsf {NY}) denotes the minimum possible cost for the first three months (disregarding any following months) that end by operating out of New York in month 3.
Define C via a recurrence.
[DP3] Consulting algorithm (1 pt) [00QR]
- October 27, 2026
Describe an efficient algorithm that takes values for n, M, and sequences of operating costs N_1, \dots , N_n and S_1, \dots , S_n, and returns the cost of an optimal plan. Justify the correctness of your algorithm and analyze its asymptotic running time.