Minimum Spanning Trees (Prim's Algorithm) Flashcards
(4 cards)
1
Q
What is a Minimum Spanning Tree (MST)?
A
A subset of a graph’s edges that connects all vertices with no cycles and minimum total edge weight.
2
Q
How does Prim’s Algorithm work?
A
Starts from any node, grows the MST by adding the smallest edge connecting a visited and unvisited node.
3
Q
What data structure optimizes Prim’s Algorithm?
A
A priority queue (e.g. min-heap) to efficiently get the minimum-weight edge.
4
Q
What is the time complexity of Prim’s Algorithm?
A
O((V + E) log V) with a min-heap and adjacency list.