Data Structures & AlgorithmsHardICPC regional · GATE CS top band

Points A(5,7), B(2,4), C(3,8), D(5,0), E(1,1), F(9,8) in the plane. The cost of joining two points is the Manhattan distance |x1−x2| + |y1−y2|. What is the minimum total cost of joining all points so that every point is connected to every other (minimum spanning tree)?

  1. A. 20
  2. B. 22
  3. C. 24
  4. D. 31

Correct answer: B. 22

Prim or Kruskal on these complete Manhattan distances gives 22. Connecting everything to one hub costs 31, and summing each point's nearest neighbour is not a spanning tree either.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic