Data Structures & AlgorithmsHardICPC regional · GATE CS top band

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

Correct answer: C. 6

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