(40 points)
Consider the following problem. The input consists of the
lengths
,
and access probabilities
,
for n files
.
The problem is to order these files on a tape so as
to minimize the expected access time. If the files are
placed in the order
then
the expected access time is
Don't let this formula throw you. The term
is the probability that you
access the ith file times the length of the first i files.
For each of the below algorithms, either give a proof that the
algorithm is correct, or a proof that the algorithm is incorrect.
- (a)
- Order the files from shortest to longest on the tape. That is,
implies that s(i) < s(j).
- (b)
- Order the files from most likely to be accessed to least likely to
be accessed. That is,
pi < pj implies that s(i) > s(j).
- (c)
- Order the the files from smallest ratio of length over access probability
to largest ratio of length over access probability.
That is,
implies that s(i) < s(j).