You are on page 1of 71

Kruskal Algorithm

Minimum Spanning Trees

Ranjeet Kumar Rout

DR. B.R. Ambedkar NIT, Jalandhar

April 12, 2017

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 1 / 27
Table of Contents

Introduction
Overview
Algorithm
Example
Complexity
Application

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 2 / 27
Introduction

This algorithm first appeared in Proceedings of the American


Mathematical Society in 1956, and was written by Joseph Kruskal.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 3 / 27
Introduction

This algorithm first appeared in Proceedings of the American


Mathematical Society in 1956, and was written by Joseph Kruskal.

It is a greedy algorithm , because at each step it adds to the forest an


edge of least possible weight.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 3 / 27
Introduction

This algorithm first appeared in Proceedings of the American


Mathematical Society in 1956, and was written by Joseph Kruskal.

It is a greedy algorithm , because at each step it adds to the forest an


edge of least possible weight.

It comes under the category of path finding algorithms search.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 3 / 27
Overview of Kruskal Algorithm:

Kruskal’s Algorithm is based directly on the generic Minimum


Spanning Tree algorithm.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 4 / 27
Overview of Kruskal Algorithm:

Kruskal’s Algorithm is based directly on the generic Minimum


Spanning Tree algorithm.
It is an algorithm in graph theory that finds a minimum spanning tree
for a connected weighted graph.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 4 / 27
Overview of Kruskal Algorithm:

Kruskal’s Algorithm is based directly on the generic Minimum


Spanning Tree algorithm.
It is an algorithm in graph theory that finds a minimum spanning tree
for a connected weighted graph.
It finds a subset of the edges that forms a tree that includes every
vertex, where the total weight of all the edges in the tree is minimized.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 4 / 27
Overview of Kruskal Algorithm:

Kruskal’s Algorithm is based directly on the generic Minimum


Spanning Tree algorithm.
It is an algorithm in graph theory that finds a minimum spanning tree
for a connected weighted graph.
It finds a subset of the edges that forms a tree that includes every
vertex, where the total weight of all the edges in the tree is minimized.
If the graph is not connected, then it finds a minimum spanning
forest.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 4 / 27
Overview of Kruskal Algorithm:

Kruskal’s Algorithm is based directly on the generic Minimum


Spanning Tree algorithm.
It is an algorithm in graph theory that finds a minimum spanning tree
for a connected weighted graph.
It finds a subset of the edges that forms a tree that includes every
vertex, where the total weight of all the edges in the tree is minimized.
If the graph is not connected, then it finds a minimum spanning
forest.
Kruskal’s algorithm is an example of a greedy algorithm because at
each step it adds to the forest an edge of least possible weight.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 4 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )
4 sort the edges of E [G ] into non decreasing order by weight w

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )
4 sort the edges of E [G ] into non decreasing order by weight w
5 for each edge (u, v ) ∈ E [G ], taken in non decreasing order by weight

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )
4 sort the edges of E [G ] into non decreasing order by weight w
5 for each edge (u, v ) ∈ E [G ], taken in non decreasing order by weight
6 if FIND − SET (u) 6= FIND − SET (v )

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )
4 sort the edges of E [G ] into non decreasing order by weight w
5 for each edge (u, v ) ∈ E [G ], taken in non decreasing order by weight
6 if FIND − SET (u) 6= FIND − SET (v )
7 then A = A ∪ {(u, v )}

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )
4 sort the edges of E [G ] into non decreasing order by weight w
5 for each edge (u, v ) ∈ E [G ], taken in non decreasing order by weight
6 if FIND − SET (u) 6= FIND − SET (v )
7 then A = A ∪ {(u, v )}
8 UNION(u, v )

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
Algorithm: MST-KRUSKAL (G, w)

1 A=Φ
2 for each vertex v ∈ V [G ]
3 MAKE − SET (v )
4 sort the edges of E [G ] into non decreasing order by weight w
5 for each edge (u, v ) ∈ E [G ], taken in non decreasing order by weight
6 if FIND − SET (u) 6= FIND − SET (v )
7 then A = A ∪ {(u, v )}
8 UNION(u, v )
9 return A

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 5 / 27
How Kruskal Algorithm works

Sort all the edges in non-decreasing order of their weight.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 6 / 27
How Kruskal Algorithm works

Sort all the edges in non-decreasing order of their weight.


Pick the smallest edge. Check if it forms a cycle with the spanning
tree formed so far.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 6 / 27
How Kruskal Algorithm works

Sort all the edges in non-decreasing order of their weight.


Pick the smallest edge. Check if it forms a cycle with the spanning
tree formed so far.
If cycle is not formed, include this edge. Else, discard it.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 6 / 27
How Kruskal Algorithm works

Sort all the edges in non-decreasing order of their weight.


Pick the smallest edge. Check if it forms a cycle with the spanning
tree formed so far.
If cycle is not formed, include this edge. Else, discard it.
Repeat step 2 until there are (V − 1) edges in the spanning tree.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 6 / 27
Example of Kruskal Algorithm

5
B D 4

2 1 3
2
8 A C
12

Given graph

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 7 / 27
Example of Kruskal Algorithm

5
B D 4 ←− Loop

2 1 3
2
Loop −→ 8 A C
12

Step 1: Remove all loops

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 8 / 27
Example of Kruskal Algorithm

5
B D 4 ←− Loop

2 1 3
2
Loop −→ 8 A C
12

Step 1: Remove all loops

Note
Any edge that starts and ends at the same vertex is called a Loop.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 8 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
12

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 9 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
12

Step 2: Remove all parallel edges between two vertices except the one
with the least weight

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 9 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
12

Step 2: Remove all parallel edges between two vertices except the one
with the least weight

Note
Remove edge with weight 12 and keep 2 between A and C.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 9 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 10 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C

Step 3: Create the edge table

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 10 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C

Step 3: Create the edge table


An edge table will contain the label of all the edges along with their
weight in ascending order.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 10 / 27
Example of Kruskal Algorithm

Make all vertex as one one set by using MakeSet(), {A}, {B}, {C }, {D}
5
B D
2 1 3
2
A C
EDGE
WEIGHT

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 11 / 27
Example of Kruskal Algorithm

Make all vertex as one one set by using MakeSet(), {A}, {B}, {C }, {D}
5
B D
2 1 3
2
A C
EDGE
WEIGHT

Fill the 1st column of the table with the edge with minimum weight.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 11 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC
WEIGHT 1

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 12 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC
WEIGHT 1
Select the edge of the next minimum weight and include it into the edge
table.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 12 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC
WEIGHT 1
Select the edge of the next minimum weight and include it into the edge
table.

Note
In case we have two or more edges with the same weight then we select
them in any order.
Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 12 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC
WEIGHT 1 2 2

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 13 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC
WEIGHT 1 2 2

Again select the edge of the next minimum weight and include it into the
edge table.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 13 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC
WEIGHT 1 2 2

Again select the edge of the next minimum weight and include it into the
edge table.
Continue this process until all the edges are filled in the edge table.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 13 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC DC
WEIGHT 1 2 2 3

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 14 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 15 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Now we can find the minimum spanning tree from the edge table.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 16 / 27
Example of Kruskal Algorithm

5
B D
2 1 3
2
A C
EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Now we can find the minimum spanning tree from the edge table.

Note
The graph has 4 vertices, so the minimum spanning tree will have 3 edges.
Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 16 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 17 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Step 4: To find the MST (Minimum Spanning Tree) we will start from the
smallest weight edge and keep selecting edges that does not form any
circuit with the previously selected edges.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 17 / 27
Example of Kruskal Algorithm:

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 18 / 27
Example of Kruskal Algorithm:

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge BC has the smallest weight 1, so we will select BC and


A = A ∪ {(B, C )} So, A = {B, C } and Sets are {B,C},{A},{D}

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 18 / 27
Example of Kruskal Algorithm:

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge BC has the smallest weight 1, so we will select BC and


A = A ∪ {(B, C )} So, A = {B, C } and Sets are {B,C},{A},{D}

B D
1

A C

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 18 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 19 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge AB has the next smallest weight 2 and it doesn’t form a circuit
with previously selected edges, so we will select AB. So, A = {A, B, C }
and Sets are {A, B, C},{D}

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 19 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge AB has the next smallest weight 2 and it doesn’t form a circuit
with previously selected edges, so we will select AB. So, A = {A, B, C }
and Sets are {A, B, C},{D}

B D
2 1

A C

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 19 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 20 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge AC has the next smallest weight 2 and it forms a circuit with
previously selected edges, so we will not select AC.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 20 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge AC has the next smallest weight 2 and it forms a circuit with
previously selected edges, so we will not select AC.

B D
2 1
2
A C

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 20 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge AC has the next smallest weight 2 and it forms a circuit with
previously selected edges, so we will not select AC.

B D
2 1
2
A C

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 21 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 22 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge DC has the next smallest weight 3 and it doesn’t form a circuit
with previously selected edges, so we will select DC. So, A = {A, B, C , D}
and Sets are {A, B, C, D}

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 22 / 27
Example of Kruskal Algorithm

EDGE BC AB AC DC BD
WEIGHT 1 2 2 3 5

The edge DC has the next smallest weight 3 and it doesn’t form a circuit
with previously selected edges, so we will select DC. So, A = {A, B, C , D}
and Sets are {A, B, C, D}

B D
2 1 3

A C

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 22 / 27
Example of Kruskal Algorithm

Since we have 3 edges connecting all the 4 vertices of the graph we will
stop now.

B D
2 1 3

A C

Required minimum spanning tree.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 23 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.
After sorting, we iterate through all edges and apply find-union
algorithm.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.
After sorting, we iterate through all edges and apply find-union
algorithm.
The find and union operations can take at most O(LogV ) time.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.
After sorting, we iterate through all edges and apply find-union
algorithm.
The find and union operations can take at most O(LogV ) time.
So overall complexity is O(ELogE + ELogV ) time.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.
After sorting, we iterate through all edges and apply find-union
algorithm.
The find and union operations can take at most O(LogV ) time.
So overall complexity is O(ELogE + ELogV ) time.
The value of E can be at most V 2 , so O(LogV ) and O(LogE ) is same.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.
After sorting, we iterate through all edges and apply find-union
algorithm.
The find and union operations can take at most O(LogV ) time.
So overall complexity is O(ELogE + ELogV ) time.
The value of E can be at most V 2 , so O(LogV ) and O(LogE ) is same.
Therefore, overall time complexity is O(ElogE ) or O(ElogV ).

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Complexity Analysis

The Time complexity of Kruskal Algorithm is O(ElogE ) or O(ElogV ).


Sorting of edges takes O(ELogE ) time.
After sorting, we iterate through all edges and apply find-union
algorithm.
The find and union operations can take at most O(LogV ) time.
So overall complexity is O(ELogE + ELogV ) time.
The value of E can be at most V 2 , so O(LogV ) and O(LogE ) is same.
Therefore, overall time complexity is O(ElogE ) or O(ElogV ).
Kruskal Algorithm has a linear memory complexity.

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 24 / 27
Applications

Artificial Intelligence
Game Development
Cognitive Science

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 25 / 27
References

Introduction to Algorithm -Thomas H. Corman,Ronald L. Rivest,


Charles F. Leiserson.
http://www.geeksforgeeks.org/greedy-algorithms-set-2-kruskals-
minimum-spanning-tree-mst/
https://www.quora.com/What-are-practical-real-life-industrial-
applications-of-Dijkstra-Kruskal-and-Prims-Algortithm

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 26 / 27
The End

Thank You

Ranjeet Kumar Rout (DR. B.R. Ambedkar NIT, Jalandhar)Kruskal Algorithm April 12, 2017 27 / 27

You might also like