Data Structures & AlgorithmsHardGATE CS · ICPC regional

Cities E, S, T, U, V are joined by roads with these travel costs: T–E 16, T–V 1, T–S 8, T–U 3, E–V 2, E–S 4, E–U 14, V–S 2, V–U 4, S–U 12. 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. 8
  2. B. 22
  3. C. 21
  4. D. 10

Correct answer: C. 21

Bitmask DP over subsets gives the minimum Hamiltonian cycle cost 21. A greedy nearest-neighbour tour costs 22, and an open path (no return leg) can be cheaper at 10.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic