Data Structures & AlgorithmsHardGATE CS · ICPC regional
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 12 5 7 10; 12 0 12 9 10; 5 12 0 10 13; 7 9 10 0 4; 10 10 13 4 0. A tour visits every vertex exactly once and returns to the start. What is the minimum total weight of such a tour?
- A. 38
- B. 41
- C. 48
- D. 54
Correct answer: A. 38
Brute force over all 24 orders of the remaining vertices gives a minimum of 38. The greedy nearest-neighbour tour gives 41, and the largest tour weight 54 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
- Strings a = "bcbbba" and b = "accc". The edit distance allows insert, delete and substitute, each costing 1 (the standard Levenshtein…
- Words ['ca', 'aa', 'dc', 'ab', 'dad', 'aca', 'aac'] (each may be used at most once). A chain is a sequence of these words in which the…
- Directed graph on vertices A, B, C, D, E, F, G with edges C→A, E→A, E→G, G→C, G→F, F→C, C→G, C→B (no weights). What is the number of…
- On an 8 × 8 chessboard with rows and columns numbered 0 to 7, a knight starts at (4, 7) and must reach (1, 0) (as (row, column)). A knight…
- A trie keeps a counter at each node, and every word of the list W = ['bbaa', 'bc', 'a', 'cbaa', 'ccac', 'a'] is inserted once per…
- A binary trie of 6-bit numbers stores the set S = [25, 51, 62, 29]. For the query x = 53, what is the maximum value of x XOR s over all s…