We are given tasks . The execution of each task requires one unit of time. We can execute one task at a time. Each task has a profit and a deadline . Profit is earned if the task is completed before the end of the unit of time.
Are all tasks completed in the schedule that gives maximum profit?
View worked solution
Answer: D
To find the schedule that maximizes profit, we use the greedy Job Sequencing with Deadlines algorithm. First, we sort the tasks in descending order of their profits:
| Task | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Profit | 30 | 25 | 23 | 20 | 18 | 18 | 16 | 15 | 10 |
| Deadline | 5 | 3 | 2 | 2 | 3 | 4 | 7 | 7 | 5 |
The maximum deadline is , so we have time slots: and . We attempt to schedule each task in its latest possible free slot before or at its deadline:
- (deadline 5): Scheduled in slot .
- (deadline 3): Scheduled in slot .
- (deadline 2): Scheduled in slot .
- (deadline 2): Slot is occupied. Scheduled in slot .
- (deadline 3): Slots , , and are all occupied. cannot be scheduled.
- (deadline 4): Scheduled in slot .
- (deadline 7): Scheduled in slot .
- (deadline 7): Slot is occupied. Scheduled in slot .
- (deadline 5): All slots are occupied. cannot be scheduled.
Thus, the scheduled tasks are and . The tasks left out are and .
Free practice · Your answers on this page are not saved.
