Tags: lecture-17, minimum spanning trees
Suppose you are running Kruskal's algorithm on the following undirected, weighted graph to find a minimum spanning tree:

In what order are the edges of this graph added to the minimum spanning tree?
(A, D), (A, C), (A, B), (C, E).
Kruskal's algorithm considers edges in increasing order of weight: (A, D) with weight 2, (A, C) with weight 5, (A, B) with weight 7, and (C, E) with weight 9 are each added since none creates a cycle. The remaining edges, (B, D) with weight 20 and (A, E) with weight 21, would create cycles.
Tags: lecture-17, minimum spanning trees
True or false: given a graph \(G\) with multiple minimum spanning trees (MSTs), Prim's and Kruskal's algorithms are guaranteed to return the same MST.
False.
When there are ties in the edge weights, the MST each algorithm returns depends on how the ties are broken, and the two algorithms consider edges in different orders. For example, in a triangle whose three edges all have the same weight, each algorithm could return any of the three MSTs, depending on the order in which it considers the edges.
Tags: lecture-17, minimum spanning trees
A maximum spanning tree of a graph is a spanning tree that has the greatest possible total edge weight. Suppose Kruskal's algorithm is modified so that instead of looping through edges in ascending order of weight, it processes them in descending order of weight. True or false: the output of this modified algorithm is guaranteed to be a maximum spanning tree.
True.
Processing edges in descending order of weight is the same as running ordinary Kruskal's algorithm on the graph with every weight negated. That finds a minimum spanning tree of the negated graph, which is a maximum spanning tree of the original graph.
Tags: lecture-17, minimum spanning trees
Consider finding the minimum spanning tree of the graph below.

Suppose you are running Prim's algorithm starting with node \(a\). What is the weight of the 2nd edge added to the minimum spanning tree?
7.
Prim's algorithm starting at \(a\) adds edges in the order \((a, c)\) (6), \((a, b)\) (7), \((b, e)\) (3), \((e, f)\) (4), \((b, g)\) (8), \((c, d)\) (10).
Again running Prim's algorithm starting with node \(a\), what is the weight of the 3rd edge added to the minimum spanning tree?
3.
Prim's algorithm starting at \(a\) adds edges in the order \((a, c)\) (6), \((a, b)\) (7), \((b, e)\) (3), \((e, f)\) (4), \((b, g)\) (8), \((c, d)\) (10).
Suppose you are running Kruskal's algorithm (not Prim's algorithm). What is the weight of the 4th edge added to the minimum spanning tree?
7.
Kruskal's algorithm adds edges in the order \((b, e)\) (3), \((e, f)\) (4), \((a, c)\) (6), \((a, b)\) (7), \((b, g)\) (8), \((c, d)\) (10), skipping \((b, f)\) (5) and \((c, g)\) (9) because they would create cycles.
What is the total weight of the minimum spanning tree?
38.
The minimum spanning tree's edges have weights 3, 4, 6, 7, 8, and 10, and \(3 + 4 + 6 + 7 + 8 + 10 = 38\).
No 🌶️ problems in this topic.