Linked answer questions

Statement for Linked Answer Questions 54 and 55:

An undirected graph G(V,E)G(V,E) contains nn (n>2n > 2) nodes named v1,v2,…,vnv_1, v_2, \dots, v_n. Two nodes vi,vjv_i, v_j are connected if and only if 0<∣i−j∣≤20 < |i - j| \le 2. Each edge (vi,vj)(v_i, v_j) is assigned a weight i+ji + j. A sample graph with n=4n = 4 is shown below.

Sample undirected graph with four vertices v1, v2, v3, v4 where edge (vi, vj) has weight i + j for 0 < |i - j| <= 2

Shared with question 55.

Question

What will be the cost of the minimum spanning tree (MST) of such a graph with nn nodes?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2011 answer key

Solution

Apply Kruskal's algorithm to find which edges are included in the MST and evaluate the closed-form summation of their weights.

  1. The graph contains vertices v1,v2,…,vnv_1, v_2, \dots, v_n. An edge (vi,vj)(v_i, v_j) exists with weight i+ji + j if and only if 0<∣i−j∣≤20 < |i - j| \le 2.
  1. List candidate edges in increasing order of weight:
  • Weight 3: (v1,v2)(v_1, v_2). Included in MST.
  • Weight 4: (v1,v3)(v_1, v_3). Included in MST.
  • Weight 5: (v2,v3)(v_2, v_3). Forms cycle with (v1,v2)(v_1, v_2) and (v1,v3)(v_1, v_3), so discarded.
  • Weight 6: (v2,v4)(v_2, v_4). Connects v4v_4 to the tree. Included in MST.
  • Weight 7: (v3,v4)(v_3, v_4). Forms cycle with (v2,v3)(v_2, v_3) paths, discarded.
  • Weight 8: (v3,v5)(v_3, v_5). Connects v5v_5 to the tree. Included in MST.
  1. In general, for any step k≥3k \ge 3, the edge (vk−2,vk)(v_{k-2}, v_k) of weight (k−2)+k=2k−2(k - 2) + k = 2k - 2 connects new vertex vkv_k to the tree without creating cycles, while edges of the form (vk−1,vk)(v_{k-1}, v_k) have larger weight 2k−12k - 1 and would create cycles.
  1. The complete set of n−1n - 1 edges in the MST consists of:
  • (v1,v2)(v_1, v_2) with weight 3.
  • (vk−2,vk)(v_{k-2}, v_k) with weight 2k−22k - 2 for all k∈{3,4,…,n}k \in \{3, 4, \dots, n\}.
  1. Compute total MST cost:
Cost=3+∑k=3n(2k−2)\text{Cost} = 3 + \sum_{k=3}^n (2k - 2)

Notice that for k=3k = 3, 2(3)−2=42(3) - 2 = 4, which is the weight of (v1,v3)(v_1, v_3).
Evaluating the sum:

∑k=3n(2k−2)=2∑j=2n−1j=2[(n−1)n2−1]=(n−1)n−2=n2−n−2\sum_{k=3}^n (2k - 2) = 2 \sum_{j=2}^{n-1} j = 2 \left[ \frac{(n-1)n}{2} - 1 \right] = (n - 1)n - 2 = n^2 - n - 2

Adding the first edge of weight 3:

Cost=3+(n2−n−2)=n2−n+1\text{Cost} = 3 + (n^2 - n - 2) = n^2 - n + 1
  1. Verification for small nn:
  • For n=3n = 3: Cost=32−3+1=7\text{Cost} = 3^2 - 3 + 1 = 7. Edges are (v1,v2)(v_1, v_2) of weight 3 and (v1,v3)(v_1, v_3) of weight 4, sum = 7.
  • For n=4n = 4: Cost=42−4+1=13\text{Cost} = 4^2 - 4 + 1 = 13. Edges are (v1,v2)(v_1, v_2) of weight 3, (v1,v3)(v_1, v_3) of weight 4, and (v2,v4)(v_2, v_4) of weight 6, sum = 13.
    The formula holds for all n>2n > 2.
Final answer

B

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2011 Computer Science and Information Technology (CS)
Question
54 of 65, printed as CS Q.54
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.