SlideShare a Scribd company logo
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

What's hot

0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
Abhishek Singh
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Kruskal's algorithm
Kruskal's algorithmKruskal's algorithm
Kruskal's algorithm
Raj Kumar Ranabhat
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
Muhammad Amjad Rana
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
Pankaj Thakur
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
Acad
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
Mohammad Ilyas Malik
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
Shareb Ismaeel
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
taimurkhan803
 
Finite automata
Finite automataFinite automata
Finite automata
Bipul Roy Bpl
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
Krishma Parekh
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
Optimal binary search tree
Optimal binary search treeOptimal binary search tree
Optimal binary search tree
Kavya P
 
Floyd warshall algorithm
Floyd warshall algorithmFloyd warshall algorithm
Floyd warshall algorithm
A. S. M. Shafi
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 

What's hot (20)

0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Kruskal's algorithm
Kruskal's algorithmKruskal's algorithm
Kruskal's algorithm
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Finite automata
Finite automataFinite automata
Finite automata
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Optimal binary search tree
Optimal binary search treeOptimal binary search tree
Optimal binary search tree
 
Floyd warshall algorithm
Floyd warshall algorithmFloyd warshall algorithm
Floyd warshall algorithm
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 

Viewers also liked

minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
sachin varun
 
Kruskal’s Algorithm
Kruskal’s AlgorithmKruskal’s Algorithm
Kruskal’s Algorithm
Syed Maniruzzaman Pabel
 
Minimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumiMinimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumi
Ibrahim Alfayoumi
 
Kruskal algorithms
Kruskal algorithmsKruskal algorithms
Kruskal algorithms
Maher Alshammari
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
Snehasis Panigrahi
 
Karmarkar's Algorithm For Linear Programming Problem
Karmarkar's Algorithm For Linear Programming ProblemKarmarkar's Algorithm For Linear Programming Problem
Karmarkar's Algorithm For Linear Programming Problem
Ajay Dhamija
 
Firefly algorithm
Firefly algorithmFirefly algorithm
Firefly algorithm
Hasan Gök
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithm
gsp1294
 
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsIntroduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Skillspeed
 
RSA Algorithm
RSA AlgorithmRSA Algorithm
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
Venkatesh Iyer
 
Cuckoo search algorithm
Cuckoo search algorithmCuckoo search algorithm
Cuckoo search algorithm
Ahmed Fouad Ali
 
Dijkstra’S Algorithm
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithm
ami_01
 

Viewers also liked (13)

minimum spanning trees Algorithm
minimum spanning trees Algorithm minimum spanning trees Algorithm
minimum spanning trees Algorithm
 
Kruskal’s Algorithm
Kruskal’s AlgorithmKruskal’s Algorithm
Kruskal’s Algorithm
 
Minimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumiMinimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumi
 
Kruskal algorithms
Kruskal algorithmsKruskal algorithms
Kruskal algorithms
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Karmarkar's Algorithm For Linear Programming Problem
Karmarkar's Algorithm For Linear Programming ProblemKarmarkar's Algorithm For Linear Programming Problem
Karmarkar's Algorithm For Linear Programming Problem
 
Firefly algorithm
Firefly algorithmFirefly algorithm
Firefly algorithm
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithm
 
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce FundamentalsIntroduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
Introduction to MapReduce | MapReduce Architecture | MapReduce Fundamentals
 
RSA Algorithm
RSA AlgorithmRSA Algorithm
RSA Algorithm
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Cuckoo search algorithm
Cuckoo search algorithmCuckoo search algorithm
Cuckoo search algorithm
 
Dijkstra’S Algorithm
Dijkstra’S AlgorithmDijkstra’S Algorithm
Dijkstra’S Algorithm
 

Similar to Kruskal’s algorithm

Graph theory1234
Graph theory1234Graph theory1234
Graph theory1234
muhamadsyafiqzaini
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithm
shreeuva
 
Triangle
TriangleTriangle
Triangle
TriangleTriangle
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
SintooChauhan6
 
Geometry working with line segments
Geometry working with  line segmentsGeometry working with  line segments
Geometry working with line segments
rfarinas
 
Angles and sides of a triangle
Angles and sides of a triangleAngles and sides of a triangle
Angles and sides of a triangle
dmidgette
 
The Law of Cosines demo
The Law of Cosines demoThe Law of Cosines demo
The Law of Cosines demo
Reymark Velasco
 
minimum spanning tree
minimum spanning tree minimum spanning tree
minimum spanning tree
Melaku Bayih Demessie
 

Similar to Kruskal’s algorithm (9)

Graph theory1234
Graph theory1234Graph theory1234
Graph theory1234
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithm
 
Triangle
TriangleTriangle
Triangle
 
Triangle
TriangleTriangle
Triangle
 
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
Decision Maths 1 Chapter 3 Algorithms on Graphs (including Floyd A2 content)....
 
Geometry working with line segments
Geometry working with  line segmentsGeometry working with  line segments
Geometry working with line segments
 
Angles and sides of a triangle
Angles and sides of a triangleAngles and sides of a triangle
Angles and sides of a triangle
 
The Law of Cosines demo
The Law of Cosines demoThe Law of Cosines demo
The Law of Cosines demo
 
minimum spanning tree
minimum spanning tree minimum spanning tree
minimum spanning tree
 

Recently uploaded

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 

Recently uploaded (20)

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 

Kruskal’s algorithm

  • 1.
  • 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