The educational insights and opportunities afforded by the nuances of Prim's and Kruskal's MST algorithms

Document Type


Publication Date



©2019 ACM The a fundamental computation topic of a minimum in any algorithms spanning course. tree (MST) In this is paper, we outline a series of projects based on a thorough exploration of the performances of two well-known MST algorithms: Prim's and Kruskal's. For a graph of n nodes and e edges, both run in O(e lg n) time but these results are based on picking the right data structures. Prim's relies on a priority queue that supports priority modification in O(lg n) time while Kruskal's relies on a disjoint-set that supports find/union operations in O(lg n) time. The performance ramifications of using simpler data structures allow students to thoroughly understand the operations of these two algorithms, get a deeper comprehension of asymptotic complexity analysis, negotiate empirical results with analytical predictions, and illustrate the value of “programming to the interface.” Our study also includes the performance consequences of the qualities of the graphs on which MSTs are computed: structure (random vs scale-free), density (sparse vs dense), and edge cost distribution. Finally, as an additional inquiry to engage students in a somewhat unexplored direction, we focus on the average pairwise-distance of the MSTs produced by Prim's vs Kruskal's.

Publication Name

ACM Inroads

Volume Number


First Page


Last Page


Issue Number




This document is currently not available here.