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?
- A. 183
- B. 95
- C. 211
- 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).
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
- A directed graph on A–H has edges B→A, B→C, C→F, C→H, D→C, E→C, E→H, F→G, F→H, G→C, H→A. How many strongly connected components does it…
- 0/1 knapsack with capacity 18: items (weight, value) = (2, 25), (5, 31), (8, 37), (4, 22), (4, 27). What is the maximum total value?
- Keys 78, 54, 58, 22, 55, 70, 25, 12, 39, 86 are inserted into an empty AVL tree (giving preorder 58, 25, 22, 12, 54, 39, 55, 78, 70, 86)…
- DFS runs on the directed graph with adjacency lists A: BDF; B: FG; C: ABE; D: G; E: –; F: D; G: A, starting at A, scanning lists in the…
- The directed graph A→C (5), A→D (4), A→E (7), B→D (2), C→B (4), C→D (1), D→E (7), E→C (-5) has one negative edge but no negative cycle…
- A binary min-heap is stored in a 0-indexed array [2, 19, 33, 58, 25, 35, 53]. Perform, in order: insert 36, insert 8, delete-min…