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 1 1 15 11 11; 1 0 13 6 9 12; 1 13 0 6 13 8; 15 6 6 0 11 9; 11 9 13 11 0 14; 11 12 8 9 14 0. A tour visits every vertex exactly once and returns to the start. What is the minimum total weight of such a tour?
- A. 56
- B. 46
- C. 75
- D. 39
Correct answer: D. 39
Brute force over all 120 orders of the remaining vertices gives a minimum of 39. The greedy nearest-neighbour tour gives 46, and the largest tour weight 75 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
- A binary trie of 6-bit numbers stores the set S = [45, 4, 46, 21]. For the query x = 48, what is the maximum value of x XOR s over all s…
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–B (1), A–C (1), A–G (1), B–G (1), C–D (1), C–F (1), C–G (1), D–E (1)…
- A binary trie of 6-bit numbers stores the set S = [23, 17, 24, 54, 21, 27, 41]. For the query x = 40, what is the maximum value of x XOR s…
- 2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as ). Current board: 4 2 / 5 1 3. Goal board: 1 2 3 / 4 5 . A move slides a…
- Distinct words ['ca', 'a', 'ba', 'abc', 'b'] are inserted into an empty trie (one node per character, shared prefixes share nodes, and a…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–C (2), A–D (3), A–E (1), B–C (3), B–E (3), C–D (3), D–E (3). An edge is…