Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2
Directed acyclic graph on vertices A, B, C, D, E, F (every edge goes from a smaller to a larger letter) with weighted edges A→B (4), A→C (6), A→F (2), B→F (7), C→D (1). What is the largest total weight of any directed path (one or more edges) in this graph?
- A. 2
- B. 7
- C. 11
- D. 20
Correct answer: C. 11
A DP over vertices in topological order gives a heaviest path of weight 11. 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
- Array A = [2, 2, 4, 4, 1, 5, 2, 3, 1]. An increasing subsequence is chosen by INDEX positions i1 < i2 < … with A[i1] < A[i2] < … (strictly…
- Undirected weighted graph on vertices A, B, C, D, E; its edges, in this listed order, are: B–D (7), A–D (7), C–D (9), D–E (3), A–C (2)…
- Directed weighted graph on vertices A, D, B, F, C (source A, target C) with edges: A→D (4); A→B (7); B→D (-6); D→C (3); B→C (1); A→C (12)…
- Directed acyclic graph on vertices A, B, C, D, E with edges A→D, A→C, D→B, D→C. Among all topological orderings (every edge goes from…
- Words ['b', 'b', 'b', 'c', 'cbca', 'aca'] are inserted in this order into an empty trie with one node per character, shared prefixes…
- Connected undirected weighted graph on vertices A, B, C, D, E, F with edges A–D (5), B–D (7), B–F (13), C–D (11), D–E (11), D–F (12), E–F…