Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2
Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→C (9), A→G (5), B→F (3), C→D (3), D→E (8). What is the largest total weight of any directed path (one or more edges) in this graph?
- A. 20
- B. 9
- C. 3
- D. 28
Correct answer: A. 20
A DP over vertices in topological order gives a heaviest path of weight 20. Counting the edges of that path, or summing every weight, gives other numbers.
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
- Connected undirected weighted graph on vertices A, B, C, D with edges A–B (6), A–D (5), B–C (3), B–D (4), C–D (4). Among all spanning…
- Directed acyclic graph on vertices A, B, C, D, E, F with edges A→F, A→C, A→E, F→D, B→E, D→C. Among all topological orderings (every edge…
- Directed acyclic graph on vertices A, B, C, D, E, F with edges B→D, A→F, A→E, D→E, F→C. Among all topological orderings (every edge goes…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–C (6), A–D (6), B–C (1), B–D (5), C–E (4), D–E (4). Among all…
- A 6 × 6 grid (rows top to bottom, '#' = filled, '.' = empty): ...... / ..#... / .#.### / ....#. / #...## / .#..#.. Two filled cells belong…
- Undirected weighted graph on vertices A, B, C, D, E, F with edges A–B (9), A–D (7), A–F (7), B–D (5), C–E (9), D–E (5), D–F (7), E–F (3)…