Data Structures & AlgorithmsHardGATE CS

Unit-time jobs (deadline, profit): J1 (3, 34), J2 (3, 62), J3 (3, 67), J4 (4, 10), J5 (3, 27), J6 (3, 79), J7 (3, 89). One job runs at a time, starting at time 0; a job earns its profit only if it finishes by its deadline. What is the maximum total profit?

  1. A. 245
  2. B. 133
  3. C. 297
  4. D. 235

Correct answer: A. 245

Sort by profit and put each job in the latest free slot ≤ its deadline; this yields 245. Scheduling by earliest deadline gives 133, and taking the top 4 profits ignores deadlines (297).

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic