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