(40 points)
You wish to drive from point A to point B along a highway
minimizing the time that you are stopped for gas.
You are told beforehand the capacity C of you gas tank in
liters, your rate F of fuel consumption in liters/kilometer,
the rate r in liters/minute
at which you can fill your tank at a gas station,
and the locations
of
the gas stations along the highway.
So if you stop to fill your tank from 2 liters to
8 liters, you would have to stop for 6/r minutes.
Consider the following two algorithms:
- (a)
- Stop at every gas station, and fill the tank with just enough gas to
make it to the next gas station.
- (b)
- Stop if and only if you
don't have enough gas to make it to the next gas station, and if you
stop, fill the tank up all the way.
For each algorithm either prove or disprove that this algorithm
correctly solves the problem.