Due 3/13 before class starts
CS350
The answers that you provide should clearly demonstrate that you understand the assignment and should provide enough information to clearly explain your solution to a peer.
In a programming language of your choice, implement Prim's greedy algorithm for finding a minimum-spanning tree in a weighted undirected graph. You can find a discussion of Prim's algorithm as well as pseudocode in 9.1 of the textbook. While you're encouraged to research and explore ideas from the internet, you should develop your own implementation and not just copy-paste someone else's implementation.
Prim's algorithm constructs a minimum spanning tree through a sequence of expanding subtrees, by greedily attaching the minimum weight edge that's not in the tree.
You should test your implementation for correctness. You should also be able to parse and test it against the graph in the following weighted edge file City Pairs. You should output the distance between each pair of vertices as well as the cumulative and total distance of the resulting minimum-spanning trees.
You should submit the following:
The source code for your implementation
A write up including the following points:
Implement Kruskal's algorithm for greedily finding a minimum-spanning tree. This requires implementing a union-find (or disjoint set) abstract data structure to keep track of which vertices of a forest are in the same connected component. A discussion of Kruksal's algorithm as well as union-find is in 9.2 of your textbook. You can find more information about union-find at the following wikipage: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
Same as above, you should test your implementation for correctness. You should also be able to parse and test it against the graph in the following weighted edge file City Pairs. You should output the distance between each pair of vertices as well as the cumulative and total distance of the resulting minimum-spanning trees.
You should submit the following:
The source code for your implementation
A write up including the following points: