Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2
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 12 8 7 13 8; 12 0 9 8 12 13; 8 9 0 3 8 2; 7 8 3 0 11 5; 13 12 8 11 0 12; 8 13 2 5 12 0. A tour visits every vertex exactly once and returns to the start. What is the minimum total weight of such a tour?
- A. 55
- B. 60
- C. 45
- D. 48
Correct answer: C. 45
Brute force over all 120 orders of the remaining vertices gives a minimum of 45. The greedy nearest-neighbour tour gives 48, and the largest tour weight 60 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
- Undirected weighted graph on vertices A, B, C, D, E, F; its edges, in this listed order, are: A–E (2), D–F (6), B–C (8), C–D (4), A–B (7)…
- Array A = [4, 3, 9, 3, 3, 9, 7] (indices 0 to 6). Count the non-empty subsets of positions (each position used at most once, subsets not…
- Distinct words ['aa', 'ab', 'ca', 'c', 'bb'] 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–B (1), A–C (1), A–E (1), B–C (2), B–D (3), C–E (1), D–E (3). How many…
- Directed weighted graph on vertices A, B, C, D, E with edges (u→v, w): C→D (8); E→C (4); D→C (8); C→E (6); D→A (4); B→E (5). Let d(x, y)…
- Weighted tree on vertices 0 to 5 with edges 0–1 (9), 0–2 (8), 1–3 (4), 3–4 (4), 1–5 (3). What is the largest possible sum of edge weights…