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

Dynamic programming You are going on a long trip. You start on the road at mile

ID: 3529895 • Letter: D

Question

Dynamic programming You are going on a long trip. You start on the road at mile post 0. Along the way there are n hotels, at mile posts a1 < a2 < ... < an, where each ai is measured from the starting point. The only places you are allowed to stop are at these hotels, but you can choose which of the hotels you stop at. You must stop at the final hotel (at distance an), which is your destination. You'd ideally like to travel 200 miles a day, but this may not be possible (depending on the spacing of the hotels). If you travel x miles during a day, the penalty for that day is (200 - x)2. You want to plan your trip so as to minimize the total penalty

Explanation / Answer

B[k] = be the optimal least penalty spent to reach from A1 to Ak

then

B[k] = min ( B[k-j] + (200 - (A[k]-A[j])^2; for j<k and A[k]-A[j] <200;

the above it the problem formulation for solving by use of dynamic programming.