Data Structures & AlgorithmsHardGATE CS · Codeforces Div 2
Points A(4,4), B(3,6), C(2,6), D(2,3), E(3,5), F(8,4) 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)?
- A. 12
- B. 11
- C. 13
- D. 16
Correct answer: B. 11
Prim or Kruskal on these complete Manhattan distances gives 11. Connecting everything to one hub costs 16, and summing each point's nearest neighbour is not a spanning tree either.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–C (1), B–D (1), B–G (1), C–D (1), C–E (1), D–E (1), E–F (1), E–G (1)…
- Keys [7, 34, 44, 32, 10, 49, 20] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right…
- Connected undirected graph on vertices A, B, C, D, E, F, G with edges A–E (1), A–G (1), B–F (1), C–D (1), D–F (1), E–F (1), E–G (1)…
- Coins of denominations [12, 10, 3, 2] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 30?…
- A binary trie of 6-bit numbers stores the set S = [52, 29, 43, 11]. For the query x = 29, what is the maximum value of x XOR s over all s…
- Undirected graph on vertices A, B, C, D, E, F, G with weighted edges A–B (6), A–G (9), B–C (6), B–G (8), C–D (6), C–F (1), D–G (8), E–F…