Question: Question 2 . ( 2 0 marks ) A catering service receives n orders, each requiring exactly one time unit to complete. There is only
Question marks A catering service receives orders, each requiring exactly one time unit to
complete. There is only one cook, so these orders must be completed one at a time; the cook starts work
at time
Order has a deadline in time units by which it must be completed, and a profit
that the catering service receives if the order is completed by the deadline; if the order is completed
after the deadline there is no profit made and therefore it is not done at all. Note that several orders may
have the same deadline eg around lunch time The catering service must decide on a schedule in which
to do a subset of the orders, each completed by its deadline.
Describe an greedy algorithm that takes as input the set of orders with their deadlines and profits
: and outputs a schedule of maximum profit. A schedule is a function that
maps each order to a time slot where is a positive integer, meaning that order i will be done during
the time interval ; or to the time slot meaning that order i will not be done. The schedule
cannot map two different orders to the same time slot because there is only one cook who completes the
orders, one at a time; and if it maps order to time slot then since every order that is
done must be finished by its deadline The profit of schedule is the sum of the orders that are done,
ie&
Prove that your algorithm is correct and analyze its running time. It can be done in time,
but is good enough for the purposes of this question.
Hint. No job can be scheduled after the maximum deadline. What job should be scheduled in the slot
ending at that deadline?
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
