GATE CS 2005 · Asymptotic Analysis & Recurrences

MCQ · 1 mark · Problem PROG-DIVC-0145

We are given 9 tasks \(T_1, T_2, \ldots, T_9\). The execution of each task requires one unit of time, and only one task can be executed at a time. Each task \(T_i\) has a profit \(P_i\) and a deadline \(d_i\); the profit \(P_i\) is earned if the task is completed before the end of the \(d_i\)-th unit of time.\[\begin{array}{|c|c|c|c|c|c|c|c|c|c|}\hline \text{Task} & T_1 & T_2 & T_3 & T_4 & T_5 & T_6 & T_7 & T_8 & T_9 \\\hline \text{Profit } P_i & 15 & 20 & 30 & 18 & 18 & 10 & 23 & 16 & 25 \\\hline \text{Deadline } d_i & 7 & 2 & 5 & 3 & 4 & 5 & 2 & 7 & 3 \\\hline \end{array}\]Are all tasks completed in the schedule that gives maximum profit?
  1. A
    All tasks are completed
  2. B
    T1 and T6 are left out
  3. C
    T1 and T8 are left out
  4. D
    T4 and T6 are left out

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solution\[\boxed{\text{Greedy: take tasks by decreasing profit, each in the latest free slot } \le d_i}\]By profit: \(T_3(30), T_9(25), T_7(23), T_2(20), T_4(18), T_5(18), T_8(16), T_1(15), T_6(10)\).\(T_3\) goes to slot 5, \(T_9\) to slot 3, \(T_7\) to slot 2, \(T_2\) to slot 1.\(T_4\) (deadline 3): slots 1 to 3 are full, so \(T_4\) is left out.\(T_5\) goes to slot 4, \(T_8\) to slot 7, \(T_1\) to slot 6.\(T_6\) (deadline 5): slots 1 to 5 are full, so \(T_6\) is left out.Maximum profit \(=175-(18+10)=147\), with \(T_4\) and \(T_6\) left out (this is the only best set).Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com