to make stops such that this total loss is minimized — that is, the sum, over all travel days, of the daily losses is minimized. Give an efficient DP algorithm that determines the optimal sequence of stopovers at which to stop so as to minimize loss. (a) Define a subproblem (b) Write a recurrence (c) Write a bottom-up algorithm to compute the subproblem solutions (d) Write a method to retrieve the optimal stopover sequence
Another Highway” You are going to Europe by road! Wow. And its one single road (wow!). You
start on the road at distance 0. There are many stopovers on this road and these are located at
different distances. You are driving the car yourself and will need to stop at some of these stopovers.
In the end, you will definitely stop at the final stopover. Your aim is to travel 500 kms every day (you
make stopover at night), as this seems to be the ideal distance that balances the fatigue with the
pleasure of travelling the most. However, it‘s not always possible to do so because the stopovers are
not always 500 kms apart from each other. (If they were, you could travel 500 Kms and make a stop,
and so on). Being of a quantitative bent of mind, you have formulated that if you travel α miles in a
day, the amount of loss ‘(in terms of more fatigue and less joy) for that day is (500 − α) 2
. You want
to make stops such that this total loss is minimized — that is, the sum, over all travel days, of the
daily losses is minimized. Give an efficient DP
stopovers at which to stop so as to minimize loss. (a) Define a subproblem (b) Write a recurrence (c)
Write a bottom-up algorithm to compute the subproblem solutions (d) Write a method to retrieve
the optimal stopover sequence that produces the optimal (minimum) value of loss.
Step by step
Solved in 4 steps with 1 images