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?
- A. 157
- B. 293
- C. 309
- 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).
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- An undirected graph has edges A–B, A–D, A–H, B–G, B–H, C–D, C–E, D–E, E–H, F–H. BFS starts at A and always scans neighbours in…
- A binary search tree holds exactly the keys 28, 41, 46, 47, 55, 66, 96, 99. Which ONE of the following sequences can be its PREORDER…
- The weighted undirected graph A–B (3), A–C (5), A–E (22), B–D (18), B–F (16), C–D (8), C–F (2), E–F (26) has a unique MST. What is the…
- The connected undirected graph with edges A–C, A–F, B–C, B–D, B–G, B–H, C–D, C–F, D–E, D–G, F–H, G–H must be walked so that every edge is…
- DFS on the directed graph with adjacency lists A: CDG; B: –; C: –; D: BCF; E: –; F: CE; G: CE starts at A (scanning lists in the order…
- What is the length of the longest BITONIC subsequence (strictly increasing then strictly decreasing; either part may be empty) of [19, 10…