Data Structures & AlgorithmsHardProduct-company placement

Unit-time jobs (deadline, profit): J1 (2, 63), J2 (1, 38), J3 (2, 38), J4 (4, 52), J5 (2, 86), J6 (1, 75), J7 (1, 40). 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. 213
  2. B. 128
  3. C. 276
  4. D. 175

Correct answer: A. 213

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic