BIL 331:Fall 2021
Homework 3
Assigned Tuesday, October 26. Your answers must be uploaded to uzak.etu.edu.tr by Saturday,
November 6, 23.59.
Problem 1. Ali wants to drive from İzmir to Erzurum. He starts with a full gas tank, and can
travel for 100 km on a full tank. Let x1 < x2 < . . . < xn denote the locations of n gas stations
along the route, measured in kilometers from İzmir. For any two consecutive gas stations
the distance between them is at most 100 km. Ali wants to stop at as few gas stations as
possible. Give an efficient greedy method to find out the gas stations for Ali to stop. Prove
the optimality of your algorithm using the exchange argument method.
Problem 2. (Kleinberg and Tardos, Chapter 4, Problem 3) You are consulting for a trucking
company that does a large amount of business shipping packages between New York and
Boston. The volume is high enough that they have to send a number of trucks each day
between the two locations. Trucks have a fixed limit W on the maximum amount of weight
they are allowed to carry. Boxes arrive at the New York station one by one, and each package
i has a weight wi . The trucking station is quite small, so at most one truck can be at the
station at any time. Company policy requires that boxes are shipped in the order they arrive;
otherwise, a customer might get upset upon seeing a box that arrived after his make it to
Boston faster. At the moment, the company is using a simple greedy algorithm for packing:
they pack boxes in the order they arrive, and whenever the next box does not fit, they send
the truck on its way. But they wonder if they might be using too many trucks, and they want
your opinion on whether the situation can be improved. Here is how they are thinking. Maybe
one could decrease the number of trucks needed by sometimes sending off a truck that was
less full, and in this way allow the next few trucks to be better packed. Prove that, for a given
set of boxes with specified weights, the greedy algorithm currently in use actually minimizes
the number of trucks that are needed. Prove this using the exchange argument method..
Problem 3. (Kleinberg and Tardos, Chapter 4, Problem 6) Your friend is working as a camp coun-
selor, and he is in charge of organizing activities for a set of junior-high-school-age campers.
One of his plans is the following mini-triathalon exercise: each contestant must swim 20 laps
of a pool, then bike 10 miles, then run 3 miles. The plan is to send the contestants out in
a staggered fashion, via the following rule: the contestants must use the pool one at a time.
In other words, first one contestant swims the 20 laps, gets out, and starts biking. As soon
as this first person is out of the pool, a second contestant begins swimming the 20 laps; as
soon as he/she’s out and starts biking, a third contestant begins swimming ... and so on.)
Each contestant has a projected swimming time (the expected time it will take him or her to
complete the 20 laps), a projected biking time (the expected time it will take him or her to
complete the 10 miles of bicycling), and a projected running time (the time it will take him
or her to complete the 3 miles of running). Your friend wants to decide on a schedule for the
triathalon: an order in which to sequence the starts of the contestants. Let’s say that the
completion time of a schedule is the earliest time at which all contestants will be finished with
1
all three legs of the triathalon, assuming they each spend exactly their projected swimming,
biking, and running times on the three parts. (Again, note that participants can bike and run
simultaneously, but at most one person can be in the pool at any time.) What’s the best order
for sending people out, if one wants the whole competition to be over as early as possible?
More precisely, give an efficient algorithm that produces a schedule whose completion time
is as small as possible. Prove the optimality of your algorithm using the exchange argument
method.