Data Structures & AlgorithmsHardGATE CS
Unit-time jobs (deadline, profit): J1 (3, 34), J2 (3, 62), J3 (3, 67), J4 (4, 10), J5 (3, 27), J6 (3, 79), J7 (3, 89). 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. 245
- B. 133
- C. 297
- D. 235
Correct answer: A. 245
Sort by profit and put each job in the latest free slot ≤ its deadline; this yields 245. Scheduling by earliest deadline gives 133, and taking the top 4 profits ignores deadlines (297).
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
- Floyd–Warshall runs on vertices 1–4 with directed edges 1→2 (4), 2→3 (11), 2→4 (11), 3→1 (7), 3→2 (6), 3→4 (8), 4→3 (11). After the…
- An undirected connected graph has edges A–B, A–E, B–G, C–G, D–E, D–G, D–I, E–G, E–I, F–H, H–I. How many articulation points (cut vertices)…
- What is the length of the longest common subsequence of MARTIAN and GRAPHICAL, and how many DISTINCT longest common subsequences (as…
- What is the length of the shortest string that has BOTH PLACEMENT and KNAPSACK as subsequences (shortest common supersequence)?
- Keys 28, 36, 45, 51, 56 are searched with frequencies 2, 3, 8, 7, 8 respectively (only successful searches). The cost of a BST is Σ…
- The weighted undirected graph A–B (1), A–D (6), A–E (4), B–C (6), B–D (4), C–D (1), C–E (4) has repeated weights. How many different…