Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
Cities F, M, O, R, S are joined by roads with these travel costs: M–O 11, M–S 20, M–R 7, M–F 16, O–S 16, O–R 14, O–F 8, S–R 11, S–F 8, R–F 18. A salesman must visit every city exactly once and return to his starting city, minimising the total cost. What is the minimum total cost?
- A. 34
- B. 45
- C. 72
- D. 46
Correct answer: B. 45
Bitmask DP over subsets gives the minimum Hamiltonian cycle cost 45. A greedy nearest-neighbour tour costs 45, and an open path (no return leg) can be cheaper at 34.
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 tree has the vertices D, F, I, O, Q, R, S, U, X and the edges I–S, I–U, I–O, I–D, D–X, D–F, U–Q, X–R. What is the minimum number of…
- A tree on the vertices E, H, K, S, U, X has the arcs E→S, S→H, H→K, U→H, X→K (each undirected edge is directed as shown). You may reverse…
- A directed graph has the vertices E, G, L, N, U and the arcs N→L, N→E, N→G, L→N, L→E, U→N, U→L, U→E, U→G, E→L, E→U, E→G, G→U, G→E. Count…
- A connected undirected graph has the vertices A, I, J, N, O, X, Z and the edges A–X, A–O, X–O, X–I, O–Z, O–N, I–N, I–J. How many bridges…
- An undirected graph has the vertices D, G, L, Q, R, X, Y and the edges R–G, Y–R, L–X, Y–G, D–R, Y–L, D–G. How many simple cycles does it…
- Grid with 3 rows and 3 columns (top to bottom). A cell marked G is a gate; '.' is a normal cell: .G. G.. ... Each step, which is a move to…