SlideShare a Scribd company logo
12
Most read
13
Most read
14
Most read
WELCOME
TO OUR
PRESENTATION
KRUSKAL’S ALGORITHM
&
PRIM’S ALGORITHM
Presented by :
Asif Ahmed Sajal #ID : 142-15-3710
Irin Afroze #ID : 142-15 3746
Minimum Connector Algorithms
Kruskal’s algorithm
1. Select the shortest edge in a
network
2. Select the next shortest edge
which does not create a cycle
3. Repeat step 2 until all vertices
have been connected
Prim’s algorithm
1. Select any vertex
2. Select the shortest edge
connected to that vertex
3. Select the shortest edge
connected to any vertex
already connected
4. Repeat step 3 until all
vertices have been
connected
A CABLE COMPANY WANT TO CONNECT FIVE VILLAGES TO THEIR
NETWORK WHICH CURRENTLY EXTENDS TO THE MARKET TOWN OF
AVONFORD. WHAT IS THE MINIMUM LENGTH OF CABLE NEEDED?
Avonford Fingley
Brinleigh Cornwell
Donster
Edan
2
7
4
5
8 6 4
5
3
8
Example
We model the situation as a network, then the problem
is to find the minimum connector for the network
A F
B C
D
E
2
7
4
5
8 6 4
5
3
8
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
List the edges in
order of size:
ED 2
AB 3
AE 4
CD 4
BC 5
EF 5
CF 6
AF 7
BF 8
CF 8
Kruskal’s Algorithm
Select the shortest
edge in the network
ED 2
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4 (or AE 4)
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4
AE 4
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the next shortest
edge which does not
create a cycle
ED 2
AB 3
CD 4
AE 4
BC 5 – forms a cycle
EF 5
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
All vertices have been
connected.
The solution is
ED 2
AB 3
CD 4
AE 4
EF 5
Total weight of tree: 18
Kruskal’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select any vertex
A
Select the shortest
edge connected to
that vertex
AB 3
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the shortest
edge connected to
any vertex already
connected.
AE 4
Prim’s Algorithm
Select the shortest
edge connected to
any vertex already
connected.
ED 2
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the shortest
edge connected to
any vertex already
connected.
DC 4
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Select the shortest
edge connected to
any vertex already
connected.
CB 5 – forms a cycle
EF 5
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
Prim’s Algorithm
A
F
B
C
D
E
2
7
4
5
8 6 4
5
3
8
All vertices have been
connected.
The solution is
ED 2
AB 3
CD 4
AE 4
EF 5
Total weight of tree: 18
•Both algorithms will always give solutions with
the same length.
•They will usually select edges in a different order
– you must show this in your workings.
•Occasionally they will use different edges – this
may happen when you have to choose between
edges with the same length. In this case there is
more than one minimum connector for the
network.
USES OF BOTH ALGORITHM
THANK YOU

More Related Content

PDF
Linear Programming (graphical method)
PPT
Prim Algorithm and kruskal algorithm
PPT
Graph traversal-BFS & DFS
PPTX
Graph traversals in Data Structures
PPTX
Dijkstra’S Algorithm
PPT
Breadth first search and depth first search
PPTX
Matrix representation of graph
PDF
Classroom Structuring
Linear Programming (graphical method)
Prim Algorithm and kruskal algorithm
Graph traversal-BFS & DFS
Graph traversals in Data Structures
Dijkstra’S Algorithm
Breadth first search and depth first search
Matrix representation of graph
Classroom Structuring

What's hot (20)

PPT
Minimum spanning tree
PDF
Graph Theory: Cut-Set and Cut-Vertices
PPTX
Prims and kruskal algorithms
PPTX
Strassen's matrix multiplication
PPTX
Minimum spanning tree (mst)
PPT
Prim's Algorithm on minimum spanning tree
PPTX
Bellman ford algorithm
PPTX
Data structure - Graph
PPT
Spanning trees
PPTX
Dijkstra Searching Algorithms.pptx
PPT
Floyd Warshall Algorithm
PDF
Dijkstra's Algorithm
PPT
minimum spanning tree
PPTX
Knapsack problem using greedy approach
PPTX
Stressen's matrix multiplication
PPTX
Minimum Spanning Tree
PPT
SINGLE-SOURCE SHORTEST PATHS
DOCX
8-Practice problems on operator precedence parser-24-05-2023.docx
PDF
Shortest Path in Graph
PPTX
DAA-Floyd Warshall Algorithm.pptx
Minimum spanning tree
Graph Theory: Cut-Set and Cut-Vertices
Prims and kruskal algorithms
Strassen's matrix multiplication
Minimum spanning tree (mst)
Prim's Algorithm on minimum spanning tree
Bellman ford algorithm
Data structure - Graph
Spanning trees
Dijkstra Searching Algorithms.pptx
Floyd Warshall Algorithm
Dijkstra's Algorithm
minimum spanning tree
Knapsack problem using greedy approach
Stressen's matrix multiplication
Minimum Spanning Tree
SINGLE-SOURCE SHORTEST PATHS
8-Practice problems on operator precedence parser-24-05-2023.docx
Shortest Path in Graph
DAA-Floyd Warshall Algorithm.pptx
Ad

Viewers also liked (20)

PPTX
Kruskal Algorithm
PPT
KRUSKAL'S algorithm from chaitra
PPTX
Spanning trees & applications
PPT
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
PPTX
A presentation on prim's and kruskal's algorithm
PDF
Prims Algorithm
PPTX
My presentation minimum spanning tree
PPT
Kruskals prims shared by: geekssay.com
PPTX
Kruskal’s Algorithm
PDF
Greedy minimum spanning tree- prim's algorithm
PPTX
Minimum spanning tree algorithms by ibrahim_alfayoumi
PPTX
Application of greedy method
PPTX
Dijkstra’s algorithm
PPTX
Review And Evaluations Of Shortest Path Algorithms
PDF
04 greedyalgorithmsii
PPT
Mst(engl)
PPTX
Kruskal’s algorithm
PPT
minimum spanning trees Algorithm
PPTX
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
PPT
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Kruskal Algorithm
KRUSKAL'S algorithm from chaitra
Spanning trees & applications
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
A presentation on prim's and kruskal's algorithm
Prims Algorithm
My presentation minimum spanning tree
Kruskals prims shared by: geekssay.com
Kruskal’s Algorithm
Greedy minimum spanning tree- prim's algorithm
Minimum spanning tree algorithms by ibrahim_alfayoumi
Application of greedy method
Dijkstra’s algorithm
Review And Evaluations Of Shortest Path Algorithms
04 greedyalgorithmsii
Mst(engl)
Kruskal’s algorithm
minimum spanning trees Algorithm
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Ad

Similar to Kruskal & Prim's Algorithm (20)

PPTX
kruskal prim
PPT
kruskal.ppt
PPTX
Minimum Spanning Tree (Data Structure and Algorithm)
PPTX
Algorithm
PPTX
Minimum Spanning Tree
PPTX
Network flow
PDF
prims and Kruskal 1.pdf
PPTX
digital electronics Design of 101 sequence detector without overlapping for...
PDF
Substation grounding grid design using Alternative Transients Program-ATP and...
PDF
3.7 GHz Microwave Amplifier Design
PPT
Catalog busbar ls 06. busduct presentation e series rev 2
PPT
Catalog busbar ls 06. busduct presentation e series rev 2
PPTX
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
PDF
Wiring Design of KUET Auditorium Building
PPTX
A tree is an acyclic, undirected, connected graph • A spanning tree of a grap...
DOCX
PARASITIC-AWARE FULL PHYSICAL CHIP DESIGN OF LNA RFIC AT 2.45GHZ USING IBM 13...
PDF
Manual_Solis-EPM3-5G-PRO_V1,1(20250429).pdf
DOCX
Making a peaking filter by Julio Marqués
PDF
Sizing the neutral in harmonic-rich environments
DOCX
Ecet 110 Success Begins / snaptutorial.com
kruskal prim
kruskal.ppt
Minimum Spanning Tree (Data Structure and Algorithm)
Algorithm
Minimum Spanning Tree
Network flow
prims and Kruskal 1.pdf
digital electronics Design of 101 sequence detector without overlapping for...
Substation grounding grid design using Alternative Transients Program-ATP and...
3.7 GHz Microwave Amplifier Design
Catalog busbar ls 06. busduct presentation e series rev 2
Catalog busbar ls 06. busduct presentation e series rev 2
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
Wiring Design of KUET Auditorium Building
A tree is an acyclic, undirected, connected graph • A spanning tree of a grap...
PARASITIC-AWARE FULL PHYSICAL CHIP DESIGN OF LNA RFIC AT 2.45GHZ USING IBM 13...
Manual_Solis-EPM3-5G-PRO_V1,1(20250429).pdf
Making a peaking filter by Julio Marqués
Sizing the neutral in harmonic-rich environments
Ecet 110 Success Begins / snaptutorial.com

Recently uploaded (20)

PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
DOCX
573137875-Attendance-Management-System-original
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Digital Logic Computer Design lecture notes
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT
Project quality management in manufacturing
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
composite construction of structures.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
web development for engineering and engineering
PPTX
Geodesy 1.pptx...............................................
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
PPT on Performance Review to get promotions
CH1 Production IntroductoryConcepts.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
573137875-Attendance-Management-System-original
OOP with Java - Java Introduction (Basics)
Internet of Things (IOT) - A guide to understanding
Operating System & Kernel Study Guide-1 - converted.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Digital Logic Computer Design lecture notes
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Project quality management in manufacturing
Foundation to blockchain - A guide to Blockchain Tech
Model Code of Practice - Construction Work - 21102022 .pdf
composite construction of structures.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
web development for engineering and engineering
Geodesy 1.pptx...............................................
CYBER-CRIMES AND SECURITY A guide to understanding
PPT on Performance Review to get promotions

Kruskal & Prim's Algorithm

  • 2. KRUSKAL’S ALGORITHM & PRIM’S ALGORITHM Presented by : Asif Ahmed Sajal #ID : 142-15-3710 Irin Afroze #ID : 142-15 3746
  • 3. Minimum Connector Algorithms Kruskal’s algorithm 1. Select the shortest edge in a network 2. Select the next shortest edge which does not create a cycle 3. Repeat step 2 until all vertices have been connected Prim’s algorithm 1. Select any vertex 2. Select the shortest edge connected to that vertex 3. Select the shortest edge connected to any vertex already connected 4. Repeat step 3 until all vertices have been connected
  • 4. A CABLE COMPANY WANT TO CONNECT FIVE VILLAGES TO THEIR NETWORK WHICH CURRENTLY EXTENDS TO THE MARKET TOWN OF AVONFORD. WHAT IS THE MINIMUM LENGTH OF CABLE NEEDED? Avonford Fingley Brinleigh Cornwell Donster Edan 2 7 4 5 8 6 4 5 3 8 Example
  • 5. We model the situation as a network, then the problem is to find the minimum connector for the network A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 6. A F B C D E 2 7 4 5 8 6 4 5 3 8 List the edges in order of size: ED 2 AB 3 AE 4 CD 4 BC 5 EF 5 CF 6 AF 7 BF 8 CF 8 Kruskal’s Algorithm
  • 7. Select the shortest edge in the network ED 2 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 8. Select the next shortest edge which does not create a cycle ED 2 AB 3 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 9. Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 (or AE 4) Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 10. Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 11. Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 BC 5 – forms a cycle EF 5 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 12. All vertices have been connected. The solution is ED 2 AB 3 CD 4 AE 4 EF 5 Total weight of tree: 18 Kruskal’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 13. A F B C D E 2 7 4 5 8 6 4 5 3 8 Select any vertex A Select the shortest edge connected to that vertex AB 3 Prim’s Algorithm
  • 14. A F B C D E 2 7 4 5 8 6 4 5 3 8 Select the shortest edge connected to any vertex already connected. AE 4 Prim’s Algorithm
  • 15. Select the shortest edge connected to any vertex already connected. ED 2 Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 16. Select the shortest edge connected to any vertex already connected. DC 4 Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 17. Select the shortest edge connected to any vertex already connected. CB 5 – forms a cycle EF 5 Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8
  • 18. Prim’s Algorithm A F B C D E 2 7 4 5 8 6 4 5 3 8 All vertices have been connected. The solution is ED 2 AB 3 CD 4 AE 4 EF 5 Total weight of tree: 18
  • 19. •Both algorithms will always give solutions with the same length. •They will usually select edges in a different order – you must show this in your workings. •Occasionally they will use different edges – this may happen when you have to choose between edges with the same length. In this case there is more than one minimum connector for the network. USES OF BOTH ALGORITHM