The educational insights and opportunities afforded by the nuances of prim’s and Kruskal’s MST algorithms
The computation of a minimum spanning tree (MST) is a fundamental topic in any algorithms course. In this 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.
Annual Conference on Innovation and Technology in Computer Science Education, ITiCSE
Erkan, Ali, "The educational insights and opportunities afforded by the nuances of prim’s and Kruskal’s MST algorithms" (2018). Faculty Articles Indexed in Scopus. 315.