I'm having trouble with this homework question. I think the main confusion comes from not identifying a basis for a counter example.
Let
P1
, . . . ,Pn
be programs stored on a disk. ProgramPi
requiresSi
megabytes of storage, and the capacity of the disk isD
megabytes. WhereD
is less than the sum of megabytes of storage
(a) maximize the number of programs held on the disk. Prove or give a counter-example: greedy algorithm that selects programs in order of increasing
Si
(b) use as much of the capacity of the disk as possible. Prove or give a counter-example: greedy algorithm that selects programs in order of decreasing
Si
Edit: Sorry for not clarifying.
For part (a) my initial try was assuming that it does not select programs in order of increasing Si
. Choosing Pa
, Pb
and Pc
where Sa<=Sb<=Sc
, after this I didn't really understand how to go further and part (b) asks the same question but decreasing Si
.