Data Structures & AlgorithmsHardICPC regional · GATE CS top band
Complete undirected graph on vertices A to E 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 4 14 8 4; 4 0 12 7 4; 14 12 0 5 4; 8 7 5 0 9; 4 4 4 9 0. A tour visits every vertex exactly once and returns to the start. What is the minimum total weight of such a tour?
- A. 47
- B. 34
- C. 25
- D. 24
Correct answer: D. 24
Brute force over all 24 orders of the remaining vertices gives a minimum of 24. The greedy nearest-neighbour tour gives 25, and the largest tour weight 47 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
- Consider the recursive function def f(n): if n < 3: return 1; return f(n-1) + f(n-3). Evaluate f(12) and count every invocation of f…
- Coins of denominations [9, 8, 7, 2] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 22?…
- Directed acyclic graph on vertices A, B, C, D, E, F, G (every edge goes from a smaller to a larger letter) with weighted edges A→C (9)…
- Connected undirected weighted graph on vertices A, B, C, D with edges A–B (6), A–D (5), B–C (3), B–D (4), C–D (4). Among all spanning…
- Directed acyclic graph on vertices A, B, C, D, E, F with edges A→F, A→C, A→E, F→D, B→E, D→C. Among all topological orderings (every edge…
- Directed acyclic graph on vertices A, B, C, D, E, F with edges B→D, A→F, A→E, D→E, F→C. Among all topological orderings (every edge goes…