What is a minimum spanning tree (MST)?
Answer
A Minimum Spanning Tree (MST) of a connected weighted undirected graph is a subset of edges that connects all vertices with the minimum possible total edge weight, forming a tree (no cycles, V-1 edges). Two classic MST algorithms: (1) Kruskal's algorithm: Greedy. Sort all edges by weight. Add an edge if it doesn't create a cycle (use Union-Find to check). Repeat until V-1 edges added. Time: O(E log E) for sorting + O(E α(V)) for Union-Find operations ≈ O(E log E). Best for sparse graphs (few edges); (2) Prim's algorithm: Greedy. Start from any vertex. Maintain a set of visited vertices. Repeatedly add the minimum weight edge that connects a visited vertex to an unvisited one. Use a priority queue. Time: O((V+E) log V) with binary heap, O(V²) with adjacency matrix (better for dense graphs). Applications: (1) Network design — minimum cost to connect all nodes (network cabling, pipeline, road construction); (2) Cluster analysis; (3) Image segmentation; (4) Approximation algorithms for NP-hard problems (TSP); (5) Borůvka's algorithm for parallel MST computation.