Data Structures & AlgorithmsHardGATE CS

Unit-time jobs (deadline, profit): J1 (3, 69), J2 (2, 89), J3 (1, 26), J4 (1, 68), J5 (2, 10), J6 (1, 83), J7 (4, 52). 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. 157
  2. B. 293
  3. C. 309
  4. D. 283

Correct answer: B. 293

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic