Kruskal's Algorithm

Kruskal’s Algorithm Code

Steps:

  1. Sort Edges: Arrange all edges in non-decreasing order of their weights.
  2. Initialize Forest: Start with a forest (each vertex is an individual tree).
  3. Edge Selection:
  4. Repeat: Continue until there are V-1 edges in the MST (V is the number of vertices).

Data Structures:

Complexity

Prim's Algorithm

Prim’s Algorithm Code

Steps: