Data Structures & AlgorithmsHardICPC regional · GATE CS top band
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 3 3 13 15 6; 3 0 13 7 2 2; 3 13 0 1 11 7; 13 7 1 0 12 15; 15 2 11 12 0 2; 6 2 7 15 2 0. A tour visits every vertex exactly once and returns to the start. What is the minimum total weight of such a tour?
- A. 69
- B. 21
- C. 37
- D. 28
Correct answer: B. 21
Brute force over all 120 orders of the remaining vertices gives a minimum of 21. The greedy nearest-neighbour tour gives 28, and the largest tour weight 69 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
- On an 7 × 7 chessboard with rows and columns numbered 0 to 6, a knight starts at (0, 3) and must reach (5, 2) (as (row, column)). A knight…
- Distinct keys [27, 2, 19, 11, 24, 4] are inserted, in the order given by the sequence [24, 11, 4, 19, 2, 27], into an empty binary search…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (2), A–D (2), A–E (1), B–D (3), B–E (2), C–E (1). An edge is CRITICAL…
- Distinct words ['aac', 'cb', 'ba', 'bc', 'a'] 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, F; its edges, in this listed order, are: C–F (2), B–D (2), D–E (7), B–C (9), D–F (2)…
- Directed weighted graph on vertices A, B, C, D, E with edges (u→v, w): C→A (8); D→E (2); B→A (9); E→D (1); B→D (1); A→E (1); E→A (9); A→B…