Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional
Connected undirected weighted graph on vertices A, B, C, D, E, F with edges A–B (14), A–C (14), A–D (6), A–E (3), B–C (16), B–D (20), B–E (18), E–F (6). What is the total weight of a maximum spanning tree (a spanning tree with the largest possible total weight)?
- A. 43
- B. 54
- C. 74
- D. 97
Correct answer: C. 74
Kruskal run on edges in decreasing weight gives 74. Running the usual ascending order returns the minimum tree, which is the trap.
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
- Undirected weighted graph on vertices A, B, C, D, E, F with edges A–C (6), A–D (9), A–E (3), A–F (6), B–C (7), B–E (3), B–F (3), D–F (3)…
- Directed acyclic graph on vertices A, B, C, D, E with edges A→C, A→E, E→B. Among all topological orderings (every edge goes from earlier…
- Distinct keys [6, 20, 4, 25, 16] are inserted, in the order given by the sequence [16, 25, 20, 6, 4], into an empty binary search tree…
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–D (1), A–F (1), A–G (1), B–C (1), B–G (1), C–D (1), C–G (1), E–G (1)…
- Array A = [6, 7, 4, 1, 8, 8, 7] (indices 0 to 6). Count the non-empty subsets of positions (each position used at most once, subsets not…
- 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…