Data Structures & AlgorithmsHardGATE CS

Unit-time jobs (deadline, profit): J1 (3, 45), J2 (2, 47), J3 (1, 77), J4 (1, 75), J5 (1, 13), J6 (2, 37), J7 (3, 59). 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. 183
  2. B. 95
  3. C. 211
  4. D. 170

Correct answer: A. 183

Sort by profit and put each job in the latest free slot ≤ its deadline; this yields 183. Scheduling by earliest deadline gives 95, and taking the top 3 profits ignores deadlines (211).

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic