Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional
Complete undirected graph on vertices A to F with symmetric edge weights given row by row (row i, column j = weight of edge between vertices i and j, with A = row 0): 0 7 2 4 13 3; 7 0 15 15 8 7; 2 15 0 12 13 11; 4 15 12 0 15 4; 13 8 13 15 0 15; 3 7 11 4 15 0. A tour visits every vertex exactly once and returns to the start. What is the minimum total weight of such a tour?
- A. 53
- B. 67
- C. 38
- D. 73
Correct answer: C. 38
Brute force over all 120 orders of the remaining vertices gives a minimum of 38. The greedy nearest-neighbour tour gives 53, and the largest tour weight 73 is a maximisation mistake.
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 weighted graph on vertices A, B, C, D, E with edges listed in this exact order: C→A (3); E→C (7); B→C (-2); B→D (6); A→B (5); C→E…
- Undirected graph on vertices A, B, C, D, E, F, G with edges A–D (1), A–E (1), A–G (1), B–C (1), B–F (1), B–G (1), D–F (1), D–G (1), E–G…
- Array A = [9, 1, 6, 12, 6, 8]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the…
- Rooted tree with root 0 and vertices 0 to 7; the edges are 0–1, 1–2, 1–3, 1–4, 3–5, 2–6, 4–7 (parent–child). Every edge has length 1. What…
- Undirected weighted graph on vertices A, B, C, D, E; its edges, in this listed order, are: D–E (3), C–E (3), A–C (2), B–C (1), A–E (8)…
- Bipartite graph with left side {A, B, C, D}, right side {E, F, G, H} and edges A–E, A–F, C–H, D–F. What is the size of a maximum matching…