Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2

Points A(3,7), B(3,5), C(9,0), D(8,2), E(5,4), F(5,6) 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. 33
  3. C. 15
  4. D. 17

Correct answer: C. 15

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