117 117 votes Let $G$ be a complete undirected graph on $4$ vertices, having $6$ edges with weights being $1, 2, 3, 4, 5,$ and $6$. The maximum possible weight that a minimum weight spanning tree of $G$ can have is __________ Algorithms gatecse-2016-set1 algorithms minimum-spanning-tree normal numerical-answers + – Sandeep Singh 55.4k views answer comment Share Follow Print See all 17 Comments 17 17 Comments reply Show 14 previous comments Debayudh_Khag commented Dec 27, 2025 reply Follow flag In MST with distinct weights, 1st minimum weight and 2nd minimum weight must be selecetd according to Kruskal. But fo the 3rd min edge will only be selected if it does not create a cycle, else the 4th minimum weight edge is selected. Here, 4 vertices so we need 3 edges. edges of weight 1 and 2 must be selected. We can not choose weight 3 in case cycle is created in graph. select weight 4. so maximum weight for MST = 1+2+4=7. 1 1 replyShare legend_of_cse commented Mar 17 reply Follow flag This is a classic "Min-Max" problem that tests your understanding of the Greedy Property of Minimum Spanning Trees. Solution for $n = 4$ A spanning tree for $n=4$ vertices must have exactly $|V| - 1 = 3$ edges. Kruskal’s algorithm picks edges in increasing order of weight, provided they don't form a cycle.The Strategy: "The Wasteful Cycle"To maximize the MST weight, we want to "waste" the smallest weights by putting them into a cycle as early as possible.Form a Triangle ($K_3$): Take 3 vertices ($v_1, v_2, v_3$) and assign them the smallest weights: $1, 2,$ and $3$.Kruskal's Execution:Pick edge weight 1 (Connects $v_1, v_2$).Pick edge weight 2 (Connects $v_2, v_3$).Edge weight 3 now forms a cycle ($v_1-v_2-v_3-v_1$). Kruskal rejects weight 3.Connect the Last Node: We still have one vertex left ($v_4$). It has 3 edges connecting it to the triangle. The remaining available weights are $\{4, 5, 6\}$. Kruskal’s is greedy, so it will pick the smallest available: weight 4.Final MST: $\{1, 2, 4\}$.Total Weight: $1 + 2 + 4 = \mathbf{7}$. Generalization for $n$ VerticesThe ProofLet $G$ be a complete graph $K_n$. The total number of edges is $N = \frac{n(n-1)}{2}$. The weights are $\{1, 2, \dots, N\}$.Isolate one vertex ($v_n$): Consider the subgraph $K_{n-1}$ formed by the other $n-1$ vertices.Fill the Subgraph: The number of edges in $K_{n-1}$ is $M = \frac{(n-1)(n-2)}{2}$. Assign the weights $\{1, 2, \dots, M\}$ to these edges.Spanning the Subgraph: Kruskal’s will process these $M$ edges first. To span $n-1$ vertices, it will pick the $n-2$ smallest edges: $1, 2, 3, \dots, (n-2)$. It will reject all other edges in this subgraph because they form cycles.Connecting $v_n$: After processing the first $M$ edges, $v_n$ is still isolated. The edges connecting $v_n$ to the rest of the graph have weights starting from $M+1$ up to $N$.The Final Edge: Kruskal’s will pick the smallest available edge to connect $v_n$, which is weight $M+1$.Mathematical DerivationThe total weight $W$ of the MST is the sum of the $n-2$ edges used to span the first $n-1$ nodes, plus the single edge used to connect the $n$-th node:$$W = \left( \sum_{i=1}^{n-2} i \right) + (M + 1)$$Substitute $M = \frac{(n-1)(n-2)}{2}$:$$W = \frac{(n-2)(n-1)}{2} + \left( \frac{(n-1)(n-2)}{2} + 1 \right)$$$$W = (n-1)(n-2) + 1$$$$W = n^2 - 3n + 3$$ VerificationFor $n=4$: $4^2 - 3(4) + 3 = 16 - 12 + 3 = \mathbf{7}$. 0 0 replyShare Riddhi_Binayika commented Aug 7 reply Follow flag We can make draw according to all different possibilities so how can we prove only 7 exactly 0 0 replyShare Please log in or register to add a comment.
Best answer 186 186 votes Many people here have not understood the question itself. Consider a complete graph of $4$ vertices. We have a total of $6$ edges of given weights but we do not have the exact graph. Many different graphs are possible each having a different structure. Consider these $2$ graphs, both of them are different. We do not know the exact structure of the graph, so what the question wants is to find the MST of all such structures and out of these tell the weight of the MST having maximum weight. The point about the MST of a graph with unique edge weights is valid for a given structure of the graph. With the same set of edge weights more than $1$ graph is possible and all of them can have different MSTs. My solution: Draw a complete graph of $4$ vertices. Sort given edges $y$ weight in increasing order. Just like Kruskal's algorithm sort the edges by weight. MST of graph with $4$ vertices and $6$ edges will have $3$ edges. Now in any case we will have to include edges with weights $1$ and $2$ as they are minimum and Kruskal's algorithm includes minimum weight edge if it does not form a cycle. We can not have a cycle with $2$ edges. In Kruskals algorithm, an edge will be rejected if it forms a cycle with the edges already selected. To increase the weight of our MST we will try to reject the edge with weight $3.$ This can be done by forming a cycle. The graph in pic1 shows this case. This implies, the total weight of this graph will be $1+2+4 = 7.$ air1 answered Nov 8, 2016 • edited Jun 19, 2021 by Lakshman Bhaiya air1 comment Share Follow See all 22 Comments 22 22 Comments reply Show 19 previous comments studyrj commented Dec 1, 2025 reply Follow flag that graph will be mst but it will not have maximum weight in that case @ISHAN_KUMRA 0 0 replyShare ISHAN KUMRA commented Dec 25, 2025 reply Follow flag yeah i got it cleared a long time ago 😅 0 0 replyShare Siddharth_Perkar commented Jun 15 reply Follow flag Minimum possible weight = w1 + w2 + w3 Maximum possible weight = w1 + w2 + w4 applicable When Kruskal runs on that K4 0 0 replyShare Please log in or register to add a comment.
104 104 votes Graph $G$ can be like this: shaiklam09 answered Feb 13, 2016 • edited Nov 16, 2017 by kenzou shaiklam09 comment Share Follow See all 19 Comments 19 19 Comments reply Show 16 previous comments shashank023 commented Dec 16, 2020 reply Follow flag @Satbir we can have edges 1 and 2, edge 3 makes cycle with 1-2, so take edge 4. Now edge 5 makes cycle with 1-4 and similarly edge 6 makes cycle with 2-4, so now we can only take edge 7. max MST weight= 1+2+4+7=14. 1 1 replyShare Rohit0911 commented Nov 19, 2024 reply Follow flag Is this not considered cycle ?? 0 0 replyShare ꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ commented Dec 27, 2024 reply Follow flag @Rohit0911 nope if middle element were there then it will be CYCLE here it is not 1 1 replyShare Please log in or register to add a comment.
32 32 votes ans is 7. it is said maximum weight pssbl. draw a triangle. 3 sides weight 1 2 3. and 4th point is in center. join it with tringle vertices.. got more 3 sides. new side weight 4 5 6. now draw mst. take 1 take 2. cant take 3, so take 4. 1+2+4=7 Debasmita Bhoumik answered Feb 12, 2016 • edited Feb 12, 2016 by Debasmita Bhoumik Debasmita Bhoumik comment Share Follow See all 9 Comments 9 9 Comments reply Show 6 previous comments Puja Mishra commented Jan 10, 2018 reply Follow flag U should hav drawn the image of ur answer ... 1 1 replyShare Sunny Mukherjee commented Jan 29, 2018 reply Follow flag explain why...dont only state 0 0 replyShare Mostafize Mondal commented Sep 5, 2018 reply Follow flag @puja.See this... 1 1 replyShare Please log in or register to add a comment.
21 21 votes Corrections or suggestions are welcomed. tanaya answered Nov 3, 2016 tanaya comment Share Follow See all 5 Comments 5 5 Comments reply Show 2 previous comments learner_geek commented Dec 28, 2017 reply Follow flag as in 2,3 (we need to select smaller one so 2 has been selected) NOTE:-just take all possible maximum and out of all possible maximum pick minimum 1 1 replyShare Sunny Mukherjee commented Jan 29, 2018 reply Follow flag @tanaya.... perfect one..thanks... finally it is clear 0 0 replyShare Amit puri commented Dec 13, 2018 reply Follow flag The best answer for this question 0 0 replyShare Please log in or register to add a comment.
15 15 votes This question ask as how many possible way of drawing the above as to find MST in which maximum possible weight, so in which we can draw only in two ways. in first way MST is 1+2+3=6 and other 1+2+4=7 no other ways can draw. so max possible weight that MST is 7. ramji answered May 18, 2016 ramji comment Share Follow 0 reply Please log in or register to add a comment.
12 12 votes The question is asked such a way that you have make the weight maximum in a MST.No matter how you draw the graph you can't make the weight more that 7,It may be 6 or 7 but they asked about maximum possible weight that the MST have.So 7 is the maximum, You can' make it more than that because that will not be MST. Pranabesh Ghosh answered Mar 14, 2016 Pranabesh Ghosh comment Share Follow See 1 comment 1 1 comment reply anchitjindal07 commented Nov 20, 2017 reply Follow flag How can we prove that weight will not more than 7 2 2 replyShare Please log in or register to add a comment.