Question: Question 1 . ( 1 5 marks ) We are given a sequence of n books of depths d 1 , d 2 , dots,
Question marks We are given a sequence of books of depths dots,see figure on the
left below We must place these books one after the other in the given order on successive shelves,
each of length maxdots, so that the sum of the depths of the books on each shelf does not
exceed
The following greedy algorithm places books on the shelves according to these rules. Intuitively it packs
as many books as possible on each shelf, and uses a new shelf if and only if the next book does not fit on
the current shelf.
a Does this algorithm minimize the sum of empty spaces on the shelves used? Justify your answer.
b Does this algorithm minimize the maximum empty space on any shelf used? Justify your answer.
Note: When disproving the correctness of a proposed algorithm, it is not sufficient to just give a coun
terexample, ie an input on which the algorithm does not work correctly. You must also indicate what the
algorithm does on your counterexample, and why that is not the correct answer. Your counterexamples
should be short and illuminating.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
