An undirected graph 𝐺(𝑉,𝐸) contains 𝑛(𝑛>2) nodes named 𝑣1,𝑣2,…,𝑣𝑛.…

2017

An undirected graph 𝐺(𝑉,𝐸)Β contains 𝑛(𝑛>2)Β nodes named 𝑣1,𝑣2,…,𝑣𝑛. Two nodes 𝑣𝑖 and 𝑣𝑗 are connected if and only ifΒ 0<βˆ£π‘–βˆ’π‘—βˆ£β‰€2. Each edgeΒ (𝑣𝑖,𝑣𝑗)Β isΒ assigned a weight 𝑖+𝑗.

Β Β Β Β The cost of the minimum spanning tree of such a graph withΒ 10Β nodes is

  1. A.

    88

  2. B.

    91

  3. C.

    49

  4. D.

    21

Attempted by 109 students.

Show answer & explanation

Correct answer: B

Key idea: use Kruskal's algorithm: sort all edges by weight and repeatedly pick the smallest edge that does not form a cycle.

Edge weights in the graph:

  • Edges between consecutive nodes i and i+1 have weight 2i+1 (for i = 1..9): 3,5,7,9,11,13,15,17,19.

  • Edges between nodes two apart i and i+2 have weight 2i+2 (for i = 1..8): 4,6,8,10,12,14,16,18.

Apply Kruskal's algorithm (choose smallest edges without creating a cycle):

  1. Pick edge (1,2) weight 3.

  2. Pick edge (1,3) weight 4 (connects node 3 to the existing component).

  3. Pick edge (2,4) weight 6.

  4. Pick edge (3,5) weight 8.

  5. Pick edge (4,6) weight 10.

  6. Pick edge (5,7) weight 12.

  7. Pick edge (6,8) weight 14.

  8. Pick edge (7,9) weight 16.

  9. Pick edge (8,10) weight 18 (this connects node 10 and completes the spanning tree).

Selected edge weights: 3, 4, 6, 8, 10, 12, 14, 16, 18.

Sum these weights: 3 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 = 91.

Answer: The cost of the minimum spanning tree for the 10-node graph is 91.

A video solution is available for this question β€” log in and enroll to watch it.

Explore the full course: Coding For Placement