Need help from an expert?
The world’s top online tutoring provider trusted by students, parents, and schools globally.
Kruskal's algorithm is a greedy algorithm used to find the minimum spanning tree of a graph.
Kruskal's algorithm works by sorting the edges of the graph in ascending order of their weights. Then, starting with the edge with the smallest weight, the algorithm checks if adding the edge to the current set of edges creates a cycle. If it does not create a cycle, the edge is added to the set of edges in the minimum spanning tree. If it does create a cycle, the edge is discarded. This process is repeated until all vertices are connected in the minimum spanning tree.
To illustrate Kruskal's algorithm, consider the following graph:

The edges are sorted in ascending order of their weights:
```
(1, 2) - 2
(2, 3) - 2
(1, 4) - 3
(3, 4) - 4
(4, 5) - 5
```
Starting with the edge with the smallest weight, (1, 2) is added to the set of edges in the minimum spanning tree. Next, (2, 3) is added. Adding (1, 4) creates a cycle, so it is discarded. Adding (3, 4) also creates a cycle, so it is discarded. Finally, (4, 5) is added to the set of edges in the minimum spanning tree. The resulting minimum spanning tree is:
```
(1, 2) - 2
(2, 3) - 2
(4, 5) - 5
```
Kruskal's algorithm has a time complexity of O(E log E), where E is the number of edges in the graph.
Study and Practice for Free
Trusted by 100,000+ Students Worldwide
Achieve Top Grades in your Exams with our Free Resources.
Practice Questions, Study Notes, and Past Exam Papers for all Subjects!
The world’s top online tutoring provider trusted by students, parents, and schools globally.