Kruskal’s Algorithm

Udyan Sharma
2 min readApr 10, 2022

We’ll talk about Kruskal’s algorithm in this blog. We’ll also look at the Kruskal’s algorithm’s difficulty, functioning, example, and implementation.

However, before diving into the technique, we must first grasp the fundamental concepts of spanning tree and minimum spanning tree.

The subgraph of an undirected connected graph is called a spanning tree while a minimum spanning tree is one in which the sum of the edge weights is the smallest possible. The total of the weights assigned to the spanning tree’s edges is the spanning tree’s weight.

For a linked weighted graph, Kruskal’s Algorithm is used to discover the minimum spanning tree. The algorithm’s main goal is to locate a subset of edges that may be used to visit every vertex of the graph. Instead of focusing on a global optimum, it uses a greedy method to discover an optimal solution at each stage.

It is important to understand the main algorithm behind Kruskal’s Algorithm. The following is an elaborate explanation of the Kruskal’s algorithm.

1. Make a forest F (a collection of trees), with each vertex in the graph representing a different tree.

2. Make a set S that contains all of the graph’s edges.

3. When S isn’t empty, and F isn’t spanning
· Remove an edge having the minimum weight from the set S
· if the removed edge joins two separate trees, add it to the forest F, merging two trees into a single tree.

The time complexity of Kruskal’s algorithm is O(E logE) or O(V logV), where V is the number of vertices and E is the number of edges.

I hope that this post summarizes the Kruskal’s Algorithm well and helps you in understanding the Kruskal’s Algorithm.

--

--

Udyan Sharma
0 Followers

A passionate entrepreneur, computer scientist, author and artificial intelligence enthusiast.