Data Structures & AlgorithmsHardProduct-company MCQ pattern

Each job takes 1 unit of time; only one job runs at a time. Jobs (deadline, profit): J1 (2, 100), J2 (1, 19), J3 (2, 27), J4 (1, 25), J5 (3, 15). What is the maximum total profit?

  1. A. 142
  2. B. 140
  3. C. 127
  4. D. 152

Correct answer: A. 142

Greedy by profit: J1 takes slot 2, J3 (deadline 2) takes slot 1, J4 and J2 find no free slot, J5 takes slot 3: 100 + 27 + 15 = 142. 152 = 100 + 27 + 25 would need three jobs finished by time 2, which is impossible.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic