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?

  1. A. 34
  2. B. 45
  3. C. 72
  4. 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.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic