Data Structures & AlgorithmsHardGATE CS · ICPC regional

Points A(5,2), B(2,4), C(6,0), D(0,3), E(8,1) 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. 14
  2. B. 16
  3. C. 15
  4. D. 18

Correct answer: A. 14

Prim or Kruskal on these complete Manhattan distances gives 14. Connecting everything to one hub costs 18, 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