SlideShare a Scribd company logo
1 of 15
Minimum
Spanning Tree
Using
Prims’s Algorithm
Design & Analysis
of Algorithm
Greedy Technique
Algorithm Design
Technique :
Problem :
Prim's Algorithm
Name: Mrunal Sanjay Patil
Roll No: 64
Year: FYMCA
 Greedy Method
• Greedy Method finds out of many options, but you have to choose
the best option.
• In this method we focused on the first stage and decide the output.
 Minimum Spanning Tree
A connected subgraph ‘M’ of graph G(V,E) is said to be spanning
Iff,
 ‘M’ should contain all vertices of ‘G’.
 ‘M’ should contain (|V|-1) edges.
𝑉1
𝑉2 𝑉3
𝑉4
𝐸1
𝐸2 𝐸4
𝐸3
Connected
Graph
Spanning Trees
𝑉1
𝑉2 𝑉3
𝑉4
𝐸1
𝐸2 𝐸4
𝐸3
 Minimum Cost Spanning Tree
• The cost of the spanning tree is the sum of the weights of all
the edges in the tree.
• Minimum spanning tree is the spanning tree where the cost is
minimum among all the spanning trees.
Undirected
Graph
4
1
3 2
5
A B
C D
Spanning Tree
Cost = 4+5+2
= 11
4
1
3 2
5
A B
C D
Minimum Cost Spanning Tree
Cost = 4+1+2
= 7
1
4 3 2
5
A B
C D
 We can find the minimum cost spanning
tree using 2 methods:
Prim’s Algorithms
Kruskal’s Algorithms
 Prim’s Algorithms
• Prim’s algorithm is a famous greedy algorithm.
• It is used for finding the Minimum Spanning Tree of a given graph.
• To apply prims algorithm, the given graph must be weighted,
connected and undirected.
 Explanation :
B
A
C
G
F
H
I
D
1
E
5 10
6
7
6
3
2
8
12
3
7
8
B
A D
1
5
C
F
3
2
E
7
H
8
G
7
I
3
Minimum Cost Spanning Tree
= Sum of all edge weight
 Cost of Minimum Spanning Tree
= 1 + 5 + 2 + 3 + 7 + 8 + 7 + 3
= 36
Program
If the input graph is presented using adjacency list , then the
time complexity of Prim’s algorithm can be reduced to O(E log V)
with the help of binary heap.
Time Complexity of the above program is
O( )
𝑉2
Thank You…

More Related Content

What's hot

Assignment problem
Assignment problemAssignment problem
Assignment problem
Abu Bashar
 
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
Simplilearn
 
Mb0048 operations research
Mb0048   operations researchMb0048   operations research
Mb0048 operations research
smumbahelp
 
Permutation graphsandapplications
Permutation graphsandapplicationsPermutation graphsandapplications
Permutation graphsandapplications
Joe Krall
 
Double Patterning (3/31 update)
Double Patterning (3/31 update)Double Patterning (3/31 update)
Double Patterning (3/31 update)
guest833ea6e
 
Double Patterning
Double PatterningDouble Patterning
Double Patterning
Danny Luk
 

What's hot (19)

Assignment problem
Assignment problemAssignment problem
Assignment problem
 
Mb0048 operations research
Mb0048 operations researchMb0048 operations research
Mb0048 operations research
 
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
What Is Dynamic Programming? | Dynamic Programming Explained | Programming Fo...
 
Always adopt self supervised learning
Always adopt self supervised learningAlways adopt self supervised learning
Always adopt self supervised learning
 
T -Coloring on Certain Graphs
T -Coloring on Certain GraphsT -Coloring on Certain Graphs
T -Coloring on Certain Graphs
 
Mb0048 operations research
Mb0048   operations researchMb0048   operations research
Mb0048 operations research
 
Multi-Chart Generative Surface Modeling
Multi-Chart Generative Surface ModelingMulti-Chart Generative Surface Modeling
Multi-Chart Generative Surface Modeling
 
Lesson 33: The Assignment Problem
Lesson 33: The Assignment  ProblemLesson 33: The Assignment  Problem
Lesson 33: The Assignment Problem
 
Lect or1 (2)
Lect or1 (2)Lect or1 (2)
Lect or1 (2)
 
Linear Programming (graphical method)
Linear Programming (graphical method)Linear Programming (graphical method)
Linear Programming (graphical method)
 
Interpolation and-its-application
Interpolation and-its-applicationInterpolation and-its-application
Interpolation and-its-application
 
Permutation graphsandapplications
Permutation graphsandapplicationsPermutation graphsandapplications
Permutation graphsandapplications
 
Image Registration (Digital Image Processing)
Image Registration (Digital Image Processing)Image Registration (Digital Image Processing)
Image Registration (Digital Image Processing)
 
Pat05 ppt 0201
Pat05 ppt 0201Pat05 ppt 0201
Pat05 ppt 0201
 
Assignment Chapter - Q & A Compilation by Niraj Thapa
Assignment Chapter  - Q & A Compilation by Niraj ThapaAssignment Chapter  - Q & A Compilation by Niraj Thapa
Assignment Chapter - Q & A Compilation by Niraj Thapa
 
How Business mathematics assist Business in decision making
How Business mathematics assist Business in decision makingHow Business mathematics assist Business in decision making
How Business mathematics assist Business in decision making
 
Double Patterning (3/31 update)
Double Patterning (3/31 update)Double Patterning (3/31 update)
Double Patterning (3/31 update)
 
Improvement of shortest path algorithms using subgraphs heuristics
Improvement of shortest path algorithms using subgraphs heuristicsImprovement of shortest path algorithms using subgraphs heuristics
Improvement of shortest path algorithms using subgraphs heuristics
 
Double Patterning
Double PatterningDouble Patterning
Double Patterning
 

Similar to Minimum Spanning Tree Using Prism's Algorithm (10)

Unit3_1.pdf
Unit3_1.pdfUnit3_1.pdf
Unit3_1.pdf
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Greedy algorithm pptxe file for computer
Greedy algorithm pptxe file for computerGreedy algorithm pptxe file for computer
Greedy algorithm pptxe file for computer
 
Minimum Spanning Tree.pptx
Minimum Spanning Tree.pptxMinimum Spanning Tree.pptx
Minimum Spanning Tree.pptx
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
Grady approach prim's spanning tree
Grady approach prim's spanning tree Grady approach prim's spanning tree
Grady approach prim's spanning tree
 
Skiena algorithm 2007 lecture13 minimum spanning trees
Skiena algorithm 2007 lecture13 minimum spanning treesSkiena algorithm 2007 lecture13 minimum spanning trees
Skiena algorithm 2007 lecture13 minimum spanning trees
 
Module 2 - Greedy Algorithm Data structures and algorithm
Module 2  - Greedy Algorithm  Data structures and algorithmModule 2  - Greedy Algorithm  Data structures and algorithm
Module 2 - Greedy Algorithm Data structures and algorithm
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programming
 
Single source Shortest path algorithm with example
Single source Shortest path algorithm with exampleSingle source Shortest path algorithm with example
Single source Shortest path algorithm with example
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Minimum Spanning Tree Using Prism's Algorithm

  • 2. Design & Analysis of Algorithm Greedy Technique Algorithm Design Technique : Problem : Prim's Algorithm Name: Mrunal Sanjay Patil Roll No: 64 Year: FYMCA
  • 3.  Greedy Method • Greedy Method finds out of many options, but you have to choose the best option. • In this method we focused on the first stage and decide the output.
  • 4.  Minimum Spanning Tree A connected subgraph ‘M’ of graph G(V,E) is said to be spanning Iff,  ‘M’ should contain all vertices of ‘G’.  ‘M’ should contain (|V|-1) edges. 𝑉1 𝑉2 𝑉3 𝑉4 𝐸1 𝐸2 𝐸4 𝐸3
  • 6.  Minimum Cost Spanning Tree • The cost of the spanning tree is the sum of the weights of all the edges in the tree. • Minimum spanning tree is the spanning tree where the cost is minimum among all the spanning trees. Undirected Graph 4 1 3 2 5 A B C D Spanning Tree Cost = 4+5+2 = 11 4 1 3 2 5 A B C D Minimum Cost Spanning Tree Cost = 4+1+2 = 7 1 4 3 2 5 A B C D
  • 7.  We can find the minimum cost spanning tree using 2 methods: Prim’s Algorithms Kruskal’s Algorithms
  • 8.  Prim’s Algorithms • Prim’s algorithm is a famous greedy algorithm. • It is used for finding the Minimum Spanning Tree of a given graph. • To apply prims algorithm, the given graph must be weighted, connected and undirected.
  • 9.  Explanation : B A C G F H I D 1 E 5 10 6 7 6 3 2 8 12 3 7 8
  • 11. = Sum of all edge weight  Cost of Minimum Spanning Tree = 1 + 5 + 2 + 3 + 7 + 8 + 7 + 3 = 36
  • 12.
  • 14. If the input graph is presented using adjacency list , then the time complexity of Prim’s algorithm can be reduced to O(E log V) with the help of binary heap. Time Complexity of the above program is O( ) 𝑉2