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.
What is the maximum profit earned?
View worked solution
Answer: A
To find the maximum profit, we use the greedy job scheduling 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 available time slots: . We schedule each task as late as possible before its deadline:
- (Profit 30, Deadline 5): Scheduled in slot .
- (Profit 25, Deadline 3): Scheduled in slot .
- (Profit 23, Deadline 2): Scheduled in slot .
- (Profit 20, Deadline 2): Slot is occupied; scheduled in slot .
- (Profit 18, Deadline 3): Slots , , and are occupied; cannot be scheduled.
- (Profit 18, Deadline 4): Scheduled in slot .
- (Profit 16, Deadline 7): Scheduled in slot .
- (Profit 15, Deadline 7): Scheduled in slot .
- (Profit 10, Deadline 5): All slots up to are occupied; cannot be scheduled.
The scheduled tasks are and .
Free practice · Your answers on this page are not saved.
