SlideShare a Scribd company logo
Kruskal’s algorithm
BENAZIR BHUTTO SHAHEED
UNVERSITY
Department of Computer Science
Under the guidance of:
Sir Ali Aurangzeb
Kruskal’s
Algorithm
PRESENTED BY:
ABDUL MOIZ KHATRI
3rd SEMESTER – Batch 6th
BECHALORS OF COMPUTER SCIENCE
PRESENTATION ON:
JOSEPH KRUSKAL
• Joseph Kruskal was an American Mathematician, Statistician and
Computer Scientist.
• He was born in January 29, 1928.
• He was a student at the University of Chicago earning a Bachelor of
Science in Mathematics in the year of 1948 and a Master of Science in
Mathematics in the following year 1949.
• After his time at the University of Chicago, Kruskal attended Princeton
University, where he completed his Ph.D. in Mathematics in the year of 1954.
• In Statistics, Kruskal's most influential work is his seminal contribution to the formulation
of Multidimensional Scaling.
• In Computer Science, his best known work is Kruskal's Algorithm for computing the Minimal
Spanning Tree (MST) of a weighted graph.
• He died in September 19, 2010.
WHAT IS AN ALGORITHM?
An Algorithm is a step-by-step procedure
to solve a given problem.
KRUSKAL’S ALGORITHM
Kruskal's Algorithm is an Algorithm for
Computing the Minimal Spanning Tree (MST)
of a Weighted Graph.
KRUSKAL’S ALGORITHM
A Minimal Spanning Tree is a Spanning Tree of
a connected, undirected graph which connects
all the vertices together with the Minimal total weightage
for its edges and it always have V-1 Edges.
A
B
C
D
1 32
Kruskal's Algorithm is an Algorithm for
Computing the Minimal Spanning Tree (MST)
of a Weighted Graph.
KRUSKAL’S ALGORITHM
A weighted graph is a graph
whose vertices or edges
have been assigned weights.
A
B
C
D
1 3
2
2
5
LETS SEE A GRAPH…!
A
B
C
D
1 3
2
2
5
Vertices
Edge
Weight of an
Edge
HOW TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM?
We will always start from the
smallest weight edge and keep
selecting edges that does not
form any circuit with the
previously selected edges.
REMEMBER….
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
We have 5 edges.
So our edge table will have 5 columns.Create the edge table.
(An edge table will have name
of all the edges along with their
weight in ascending order)
Edge
Weight
STEPS TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
Edge
Weight
Now look at the graph and fill the
1st column with the edge of minimum weight.
In this case edge BC is of least weight
so we will select it.
BC
1
Now look at the graph again and find the
edge of next minimum weight.
In this case edge AB and AC are having
the minimum weight so we will select
them both.
Note!
In case we have two or more
edges with same weight then
we can write them in any order
in the edge table.
AB
2
AC
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
Edge
Weight
BC
1
Now look at the graph again and find the
edge of next minimum weight.
In this case edge AB and AC are having
the minimum weight so we will select
them both.
Note!
In case we have two or more
edges with same weight then
we can write them in any order
in the edge table.
AB
2
AC
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
Edge
Weight
BC
1
AB
2
AC
2
Now look at the graph again and
find the edge of next minimum edge.
In this case edge DC has the
minimum weight so we will select it.
DC
2
Now look at the graph again
and find the edge of next
minimum edge.
In this case edge BD has the
minimum weight so we will
select it.
BD
5
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
Note! Our graph has 4 vertices.
So, our MST will have 3 edges.
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
1 is the smallest weight.
So we will select edge BC.
B
C
1
A
B
C
D
1 3
2
2
5
A
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
2 is the next smallest
weight and edge AB does
not form a circuit with the
previously selected edges.
So we will select it.
B
C
1
A
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
2 is the smallest weight.
But if we select edge AC
then it will form a circuit. So
we are going to reject edge AC.
B
C
1
D
3
A
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
3 is the next smallest weight and
edge DC does not form a circuit
with the previously selected edges.
So we will select it.
B
C
1
D
3
A
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
3 is the next smallest weight and
edge DC does not form a circuit
with the previously selected edges.
So we will select it.
B
C
1
D
3
A
2
A
B
C
D
1 3
2
2
5
We will always start from the smallest weight edge and keep selecting edges
that does not form any circuit with the previously selected edges.
TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S
ALGORITHM
Edge
Weight
BC
1
AB
2
AC
2
DC
2
BD
5
B
C
1
Since we have got the 3 edges.
So we will stop here.
THEREFORE, OUR REQUIRED MINIMUM SPANNING TREE IS
D
3
A
2
B
C
1
QUERIES
SESSION
THANKS
ALOT…..

More Related Content

PPTX
Kruskal Algorithm
PPTX
Namami Gange by Mandeep Poonia
PPTX
Ch3. agile sw dev
PPTX
Kruskal's algorithm
PPTX
Travelling salesman dynamic programming
PPT
Ganga action plan
PPTX
Context free grammar
PPTX
Basic organization of computer
Kruskal Algorithm
Namami Gange by Mandeep Poonia
Ch3. agile sw dev
Kruskal's algorithm
Travelling salesman dynamic programming
Ganga action plan
Context free grammar
Basic organization of computer

What's hot (20)

PPT
Spanning trees
PPT
17. Trees and Graphs
PPTX
Prim's algorithm
PPT
Minimum spanning tree
PPT
KRUSKAL'S algorithm from chaitra
PPTX
Dijkstra’S Algorithm
PPTX
Prims and kruskal algorithms
PPTX
Data structure - Graph
PPT
Randomized algorithms ver 1.0
PPTX
Knapsack problem using greedy approach
PPT
The Floyd–Warshall algorithm
PPTX
Doubly Linked List
PPT
Dinive conquer algorithm
PPTX
PRIM'S ALGORITHM
PPTX
DAA-Floyd Warshall Algorithm.pptx
PPTX
prim's and kruskal's algorithm
PPT
Divide and conquer
PPTX
Graph in data structure
PPT
3.9 external sorting
PPT
Prim's Algorithm on minimum spanning tree
Spanning trees
17. Trees and Graphs
Prim's algorithm
Minimum spanning tree
KRUSKAL'S algorithm from chaitra
Dijkstra’S Algorithm
Prims and kruskal algorithms
Data structure - Graph
Randomized algorithms ver 1.0
Knapsack problem using greedy approach
The Floyd–Warshall algorithm
Doubly Linked List
Dinive conquer algorithm
PRIM'S ALGORITHM
DAA-Floyd Warshall Algorithm.pptx
prim's and kruskal's algorithm
Divide and conquer
Graph in data structure
3.9 external sorting
Prim's Algorithm on minimum spanning tree
Ad

Viewers also liked (13)

PPT
minimum spanning trees Algorithm
PPTX
A presentation on prim's and kruskal's algorithm
PPTX
Kruskal’s Algorithm
PPTX
Minimum spanning tree algorithms by ibrahim_alfayoumi
PPTX
Kruskal & Prim's Algorithm
PPTX
Kruskal algorithms
PPTX
Kruskal Algorithm
PDF
Karmarkar's Algorithm For Linear Programming Problem
PPTX
Firefly algorithm
PPTX
Dijkstra's algorithm
PPTX
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
PPT
Introduction to Algorithms
minimum spanning trees Algorithm
A presentation on prim's and kruskal's algorithm
Kruskal’s Algorithm
Minimum spanning tree algorithms by ibrahim_alfayoumi
Kruskal & Prim's Algorithm
Kruskal algorithms
Kruskal Algorithm
Karmarkar's Algorithm For Linear Programming Problem
Firefly algorithm
Dijkstra's algorithm
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to Algorithms
Ad

Similar to Kruskal’s algorithm (10)

PPTX
Kruskal’s Algorithm: Finding the Minimum Spanning Tree
DOC
Graph theory1234
PPTX
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
PPTX
Geometry working with line segments
PPTX
Angles and sides of a triangle
PPTX
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
PPT
The Law of Cosines demo
PPT
minimum spanning tree
Kruskal’s Algorithm: Finding the Minimum Spanning Tree
Graph theory1234
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Geometry working with line segments
Angles and sides of a triangle
uva-201026072839.pptxvcvczcvzvcxbxcvbcxvbvcxbcx
The Law of Cosines demo
minimum spanning tree

Recently uploaded (20)

PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharma ospi slides which help in ospi learning
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Module 4: Burden of Disease Tutorial Slides S2 2025
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Complications of Minimal Access Surgery at WLH
Microbial disease of the cardiovascular and lymphatic systems
Pharma ospi slides which help in ospi learning
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Pre independence Education in Inndia.pdf
Renaissance Architecture: A Journey from Faith to Humanism
O5-L3 Freight Transport Ops (International) V1.pdf
GDM (1) (1).pptx small presentation for students
TR - Agricultural Crops Production NC III.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial diseases, their pathogenesis and prophylaxis
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
O7-L3 Supply Chain Operations - ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf

Kruskal’s algorithm

  • 2. BENAZIR BHUTTO SHAHEED UNVERSITY Department of Computer Science Under the guidance of: Sir Ali Aurangzeb
  • 3. Kruskal’s Algorithm PRESENTED BY: ABDUL MOIZ KHATRI 3rd SEMESTER – Batch 6th BECHALORS OF COMPUTER SCIENCE PRESENTATION ON:
  • 4. JOSEPH KRUSKAL • Joseph Kruskal was an American Mathematician, Statistician and Computer Scientist. • He was born in January 29, 1928. • He was a student at the University of Chicago earning a Bachelor of Science in Mathematics in the year of 1948 and a Master of Science in Mathematics in the following year 1949. • After his time at the University of Chicago, Kruskal attended Princeton University, where he completed his Ph.D. in Mathematics in the year of 1954. • In Statistics, Kruskal's most influential work is his seminal contribution to the formulation of Multidimensional Scaling. • In Computer Science, his best known work is Kruskal's Algorithm for computing the Minimal Spanning Tree (MST) of a weighted graph. • He died in September 19, 2010.
  • 5. WHAT IS AN ALGORITHM? An Algorithm is a step-by-step procedure to solve a given problem.
  • 7. Kruskal's Algorithm is an Algorithm for Computing the Minimal Spanning Tree (MST) of a Weighted Graph. KRUSKAL’S ALGORITHM A Minimal Spanning Tree is a Spanning Tree of a connected, undirected graph which connects all the vertices together with the Minimal total weightage for its edges and it always have V-1 Edges. A B C D 1 32
  • 8. Kruskal's Algorithm is an Algorithm for Computing the Minimal Spanning Tree (MST) of a Weighted Graph. KRUSKAL’S ALGORITHM A weighted graph is a graph whose vertices or edges have been assigned weights. A B C D 1 3 2 2 5
  • 9. LETS SEE A GRAPH…! A B C D 1 3 2 2 5 Vertices Edge Weight of an Edge
  • 10. HOW TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM? We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. REMEMBER….
  • 11. A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. We have 5 edges. So our edge table will have 5 columns.Create the edge table. (An edge table will have name of all the edges along with their weight in ascending order) Edge Weight STEPS TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM
  • 13. A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. Edge Weight Now look at the graph and fill the 1st column with the edge of minimum weight. In this case edge BC is of least weight so we will select it. BC 1 Now look at the graph again and find the edge of next minimum weight. In this case edge AB and AC are having the minimum weight so we will select them both. Note! In case we have two or more edges with same weight then we can write them in any order in the edge table. AB 2 AC 2
  • 14. A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. Edge Weight BC 1 Now look at the graph again and find the edge of next minimum weight. In this case edge AB and AC are having the minimum weight so we will select them both. Note! In case we have two or more edges with same weight then we can write them in any order in the edge table. AB 2 AC 2
  • 15. A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. Edge Weight BC 1 AB 2 AC 2 Now look at the graph again and find the edge of next minimum edge. In this case edge DC has the minimum weight so we will select it. DC 2 Now look at the graph again and find the edge of next minimum edge. In this case edge BD has the minimum weight so we will select it. BD 5
  • 16. A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 Note! Our graph has 4 vertices. So, our MST will have 3 edges.
  • 17. We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 1 is the smallest weight. So we will select edge BC. B C 1 A B C D 1 3 2 2 5
  • 18. A 2 A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 2 is the next smallest weight and edge AB does not form a circuit with the previously selected edges. So we will select it. B C 1
  • 19. A 2 A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 2 is the smallest weight. But if we select edge AC then it will form a circuit. So we are going to reject edge AC. B C 1
  • 20. D 3 A 2 A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 3 is the next smallest weight and edge DC does not form a circuit with the previously selected edges. So we will select it. B C 1
  • 21. D 3 A 2 A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 3 is the next smallest weight and edge DC does not form a circuit with the previously selected edges. So we will select it. B C 1
  • 22. D 3 A 2 A B C D 1 3 2 2 5 We will always start from the smallest weight edge and keep selecting edges that does not form any circuit with the previously selected edges. TIME TO FIND MINIMAL SPANNING TREE (MST) BY USING KRUSKAL’S ALGORITHM Edge Weight BC 1 AB 2 AC 2 DC 2 BD 5 B C 1 Since we have got the 3 edges. So we will stop here.
  • 23. THEREFORE, OUR REQUIRED MINIMUM SPANNING TREE IS D 3 A 2 B C 1