Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2 C
Directed acyclic graph on vertices 0 to 6 with weighted edges (u→v (w)): 3→2 (8), 2→6 (7), 4→6 (9), 0→2 (5), 4→2 (2), 5→1 (9), 3→5 (4), 0→6 (8). What is the largest total weight of a directed path that starts at 0 and ends at 6?
- A. 8
- B. 9
- C. 12
- D. 15
Correct answer: C. 12
Processing vertices in topological order gives 12. The shortest-path distance (8) minimises instead of maximising, and letting the path start anywhere (15) ignores the required start at 0.
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
- Directed acyclic graph on vertices 0 to 7 with weighted edges (u→v (w)): 2→7 (1), 0→7 (4), 4→2 (4), 6→2 (9), 0→1 (9), 0→6 (1), 4→5 (6)…
- Directed graph on vertices 0 to 7 with non-negative weights (u→v (w)): 3→4 (3), 0→6 (18), 6→7 (2), 4→5 (3), 0→2 (15), 1→0 (15), 1→6 (17)…
- Directed graph on vertices 0 to 5 with non-negative weights (u→v (w)): 3→0 (19), 0→1 (3), 1→2 (2), 3→4 (1), 3→5 (8), 4→3 (8), 0→3 (14)…
- Directed graph on vertices 0 to 5 with non-negative weights (u→v (w)): 1→0 (12), 4→3 (9), 3→5 (8), 3→4 (1), 5→3 (6), 0→1 (2), 5→2 (15)…
- Directed graph on vertices 0 to 5 with non-negative weights (u→v (w)): 0→4 (17), 0→1 (3), 1→2 (1), 3→5 (10), 3→4 (1), 2→3 (1), 4→5 (1)…
- Directed graph on vertices 0 to 6 with non-negative weights (u→v (w)): 4→3 (11), 4→5 (1), 0→5 (17), 6→3 (12), 0→1 (1), 3→6 (13), 2→3 (3)…