SlideShare a Scribd company logo
1 of 34
D.STEFFY(140071601072)
R.TASNIM TABASUM(140071601080)
THIRD YEAR CSE-B
ALGORITHM DESIGN AND ANALYSIS LAB(CSB 3105)
B.S.ABDUR RAHMAN UNIVERSITY
DONE BY:
1
 Problem Identification
 Definition Of Spanning Tree &Minimum Spanning Tree
 Algorithms used and its design
 Algorithm analysis
 Scenario Explanation
 Comparison between prim’s and Kruskal's algorithm
 Properties of Minimum Spanning Tree
2
3
PROBLEM IDENTIFICATION
 A cable TV company is laying cable in a new neighborhood. There is a condition
for them to bury the cable only along certain paths .
 In those paths, some might be very expensive to bury the cable because they are
longer, or require the cable to be buried deeper.
 A minimum spanning tree is a spanning tree which has a minimum total cost.
4
Definition : Spanning Tree & Minimum Spanning
Tree
 A spanning Tree of a connected graph G is its connected sub graph that
contains all the vertices of the graph.
 A Minimum Spanning Tree of a weighted connected graph G is its spanning
tree of the smallest weight where the weight of the tree is defined as the sum
of the weights on all its edges.
 A Minimum Spanning Tree exists if and only if G is connected.
5
6
Algorithms used To Find Minimum Spanning Tree
There are two algorithms used to find the minimum spanning tree of a
connected graph G.
7
Prim’s Algorithm
 Prim’s algorithm is one of the way to compute a minimum spanning tree.
 Initially discovered in 1930 by Vojtěch Jarník, then rediscovered in 1957 by
Robert C. Prim.
 This algorithm begins with a set U initialized to{1}.It then grows a spanning tree ,
one edge at a time.
 At each step , it finds a shortest edge (u ,v ) such that the cost of (u , v) is the
smallest among all edges , where u is in Minimum Spanning Tree and V is not in
Minimum Spanning Tree
 Complexity:O(v2)
8
Kruskal’s Algorithm
Step 1: Sort all edges in non-decreasing order of their weight.
Step 2: Pick the smallest edge.
Step 3:Check if it forms a cycle with Spanning Tree formed so far.
Step 4:If cycle is not formed , include this edge else discard it.
Step 5:Repeat Union-Find algorithm until there are V-1 edges in the spanning tree.
Complexity:O(ElogV) 9
10
ALGORITHMS
Two algorithms are used to find minimum spanning tree.
11
12
PRIM’S ALGORITHM
Place the starting node in the tree.
Repeat until all nodes are in the tree are visited:
Find all edges which is adjacent to source vertex.
Of those edges, choose one with the minimum weight.
Add that edge and the connected node to the tree.
A B
C
13
E
ANALYSIS
 Prim’s algorithm complexity varies based on the representation of the graph.
 In adjacency matrix representation, prim’s algorithm requires O(V2) running
time.
 Because, in adjacency representation linearly searching an array of weights to
find the minimum weight edge and to add that edge will require O(v2) running
time.
14
15
ALGORITHM

16
CONTINUES………
17
18
Problem : Laying TV Cable
Central office
19
Graph G
Central office
Expensive!!!! & cost:94
18
3
5
1
210
3
1
16
8
9
5
7
4
2A
B
C
D
E
F
G
H
V Know
n
dv Pv
A 0 0 0
B 0 ∞ 0
C 0 ∞ 0
D 0 ∞ 0
E 0 ∞ 0
F 0 ∞ 0
G 0 ∞ 0
H 0 ∞ 0
CO 0 ∞ 0
20
WHY PRIM’S ALGORITHM?
Graph is a connected graph
Since ,Graph which represents this scenario is looks like a dense graph.
Prim’s algorithm works well in dense graphs.
Prim’s algorithm complexity will be O(v2)
21
Problem : Laying TV Cable->Step 1
Central office
A
B
C
D
E
F
G
H
Source vertex
22
Problem : Laying TV Cable->step 2
Central office
A
B
C
D
E
F
G
H
1
V Known dv Pv
A 1 0 0
B 0 1 A
C 0 ∞ 0
D 0 ∞ 0
E 0 ∞ 0
F 0 ∞ 0
G 0 ∞ 0
H 0 ∞ 0
CO 0 ∞ 0
23
Problem : Laying TV Cable
Central office
A
B
C
D
E
F
G
H
1
3
V Known dv Pv
A 1 0 0
B 1 1 A
C 0 3 B
D 0 ∞ 0
E 0 ∞ 0
F 0 ∞ 0
G 0 ∞ 0
H 0 ∞ 0
CO 0 ∞ 0
24
Problem : Laying TV Cable->step 3
Central office
A
B
C
D
E
F
G
H
1
3
5
V Known dv Pv
A 1 0 0
B 1 1 A
C 1 3 B
D 0 5 c
E 0 ∞ 0
F 0 ∞ 0
G 0 ∞ 0
H 0 ∞ 0
CO 0 ∞ 025
Final step : Minimum Spanning Tree
B
C
D
E
H
G
F
Central office
A
Minimum Cost=24
1
4
3
3
1
5
2
5
V Known dv Pv
A 1 0 0
B 1 1 A
C 1 3 B
D 1 5 C
E 1 3 CO
F 1 5 E
G 1 2 F
H 1 1 G
CO 1 4 D
26
27
COMPARISON
PRIM’S ALGORITHM
Initializes with node
MST grows like a tree
Graph must be a connected
graph
Time complexity is O(v2)
Works well in dense graphs
KRUSKAL’S ALGORITHM
Initializes with an edge
MST grows like a forest
Works well in non connected
graphs also.
Time complexity is O(E log E)
Works well in sparse graphs
28
29
Properties Of Minimum Spanning Tree
1.Possible Multiplicity:
 There may be several minimum spanning trees of the same weight having
a minimum number of edges
 If all the edge weights of a given graph are the same, then every spanning
tree of that graph is minimum.
 If there are n vertices in the graph, then each minimum spanning tree has
n-1 edges.
30
Example:
Graph G Minimum spanning tree 1 Minimum spanning tree 2
31
Continues….
2.Uniqueness:
 If each edge has a distinct weight then there will be only one, unique minimum
spanning tree.
3.Cyclic property:
 For any cycle C in the graph G , if the weight of an edge of e of c is larger than the
individual weights of all other edges of c , then this edge cannot belong to MST.
C 32
Continues….
4.Minimum Cost Edge:
If the minimum cost edge e of a graph is unique, then this edge is
included in any MST.
33
34

More Related Content

What's hot

A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmGaurav Kolekar
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmAcad
 
Kruskal & Prim's Algorithm
Kruskal & Prim's AlgorithmKruskal & Prim's Algorithm
Kruskal & Prim's AlgorithmIfad Rahman
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structurehamza javed
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning treeAlona Salva
 
2.4 mst prim’s algorithm
2.4 mst  prim’s algorithm2.4 mst  prim’s algorithm
2.4 mst prim’s algorithmKrish_ver2
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra Sahil Kumar
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithmSrikrishnan Suresh
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first searchHossain Md Shakhawat
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraguest1f4fb3
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithmsSaga Valsalan
 

What's hot (20)

A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
 
Prim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithmPrim Algorithm and kruskal algorithm
Prim Algorithm and kruskal algorithm
 
Minimum spanning Tree
Minimum spanning TreeMinimum spanning Tree
Minimum spanning Tree
 
Kruskal & Prim's Algorithm
Kruskal & Prim's AlgorithmKruskal & Prim's Algorithm
Kruskal & Prim's Algorithm
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
Kruskal’s algorithm
Kruskal’s algorithmKruskal’s algorithm
Kruskal’s algorithm
 
2.4 mst prim’s algorithm
2.4 mst  prim’s algorithm2.4 mst  prim’s algorithm
2.4 mst prim’s algorithm
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Graph theory
Graph theory Graph theory
Graph theory
 
Graphs
GraphsGraphs
Graphs
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Kruskal's algorithm
Kruskal's algorithmKruskal's algorithm
Kruskal's algorithm
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
 
PRIM'S ALGORITHM
PRIM'S ALGORITHMPRIM'S ALGORITHM
PRIM'S ALGORITHM
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
 

Viewers also liked

Presentationfhs 110808045337-phpapp02
Presentationfhs 110808045337-phpapp02Presentationfhs 110808045337-phpapp02
Presentationfhs 110808045337-phpapp02Punit_Agarwal
 
Flow control
Flow controlFlow control
Flow controlSTEFFY D
 
%22Cracking India%22 Unit Plan and Analysis
%22Cracking India%22 Unit Plan and Analysis%22Cracking India%22 Unit Plan and Analysis
%22Cracking India%22 Unit Plan and AnalysisGriffin Muckley
 
Lores BLANK Catalog
Lores BLANK CatalogLores BLANK Catalog
Lores BLANK CatalogJoyce Orloff
 
Atul Joshi - Oct 2016
Atul Joshi - Oct 2016Atul Joshi - Oct 2016
Atul Joshi - Oct 2016Atul Joshi
 
Nahha Course Catalog (2)
Nahha Course Catalog (2)Nahha Course Catalog (2)
Nahha Course Catalog (2)iHawaiidigital
 
Bitcoin weekly update oct 12th oct 18th
Bitcoin weekly update oct 12th   oct 18thBitcoin weekly update oct 12th   oct 18th
Bitcoin weekly update oct 12th oct 18th99Coins ltd.
 
SWISS BULLION TABLES
SWISS BULLION TABLESSWISS BULLION TABLES
SWISS BULLION TABLESYesh Lazarte
 
Trane: Pasos para automatizar un hogar y oficina sin cables
Trane: Pasos para automatizar un hogar y oficina sin cables Trane: Pasos para automatizar un hogar y oficina sin cables
Trane: Pasos para automatizar un hogar y oficina sin cables Trane México
 

Viewers also liked (13)

Abeer Barghouti 2
Abeer Barghouti 2Abeer Barghouti 2
Abeer Barghouti 2
 
Presentationfhs 110808045337-phpapp02
Presentationfhs 110808045337-phpapp02Presentationfhs 110808045337-phpapp02
Presentationfhs 110808045337-phpapp02
 
Flow control
Flow controlFlow control
Flow control
 
StrenghtsFinder
StrenghtsFinderStrenghtsFinder
StrenghtsFinder
 
%22Cracking India%22 Unit Plan and Analysis
%22Cracking India%22 Unit Plan and Analysis%22Cracking India%22 Unit Plan and Analysis
%22Cracking India%22 Unit Plan and Analysis
 
Hirches_6Pg_v2
Hirches_6Pg_v2Hirches_6Pg_v2
Hirches_6Pg_v2
 
Lores BLANK Catalog
Lores BLANK CatalogLores BLANK Catalog
Lores BLANK Catalog
 
Atul Joshi - Oct 2016
Atul Joshi - Oct 2016Atul Joshi - Oct 2016
Atul Joshi - Oct 2016
 
Nahha Course Catalog (2)
Nahha Course Catalog (2)Nahha Course Catalog (2)
Nahha Course Catalog (2)
 
Bitcoin weekly update oct 12th oct 18th
Bitcoin weekly update oct 12th   oct 18thBitcoin weekly update oct 12th   oct 18th
Bitcoin weekly update oct 12th oct 18th
 
Holy prophet (S.A.W)
Holy prophet (S.A.W)Holy prophet (S.A.W)
Holy prophet (S.A.W)
 
SWISS BULLION TABLES
SWISS BULLION TABLESSWISS BULLION TABLES
SWISS BULLION TABLES
 
Trane: Pasos para automatizar un hogar y oficina sin cables
Trane: Pasos para automatizar un hogar y oficina sin cables Trane: Pasos para automatizar un hogar y oficina sin cables
Trane: Pasos para automatizar un hogar y oficina sin cables
 

Similar to Minimum spanning tree

Ijciras1101
Ijciras1101Ijciras1101
Ijciras1101zhendy94
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...KUSHDHIRRA2111026030
 
Shortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfShortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfzefergaming
 
Comparative Report Ed098
Comparative Report Ed098Comparative Report Ed098
Comparative Report Ed098mikebrowl
 
Minimal spanning tree class 15
Minimal spanning tree class 15Minimal spanning tree class 15
Minimal spanning tree class 15Kumar
 
Ram minimum spanning tree
Ram   minimum spanning treeRam   minimum spanning tree
Ram minimum spanning treeRama Prasath A
 
Algorithm chapter 9
Algorithm chapter 9Algorithm chapter 9
Algorithm chapter 9chidabdu
 
OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.IJERA Editor
 
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 treeszukun
 
Network and Tree in Graph Theory
Network and Tree in Graph TheoryNetwork and Tree in Graph Theory
Network and Tree in Graph TheoryRabin BK
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Mohanlal Sukhadia University (MLSU)
 

Similar to Minimum spanning tree (20)

8_MST_pptx.pptx
8_MST_pptx.pptx8_MST_pptx.pptx
8_MST_pptx.pptx
 
Ijciras1101
Ijciras1101Ijciras1101
Ijciras1101
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
Shortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfShortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdf
 
Weighted graphs
Weighted graphsWeighted graphs
Weighted graphs
 
Comparative Report Ed098
Comparative Report Ed098Comparative Report Ed098
Comparative Report Ed098
 
1 sollins algorithm
1 sollins algorithm1 sollins algorithm
1 sollins algorithm
 
Minimal spanning tree class 15
Minimal spanning tree class 15Minimal spanning tree class 15
Minimal spanning tree class 15
 
Ram minimum spanning tree
Ram   minimum spanning treeRam   minimum spanning tree
Ram minimum spanning tree
 
Algorithm chapter 9
Algorithm chapter 9Algorithm chapter 9
Algorithm chapter 9
 
Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
 
OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.OTP, Phishing, QR code, Shares, Visual Cryptography.
OTP, Phishing, QR code, Shares, Visual Cryptography.
 
Siegel
SiegelSiegel
Siegel
 
DAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptxDAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptx
 
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
 
17 prims-kruskals (1)
17 prims-kruskals (1)17 prims-kruskals (1)
17 prims-kruskals (1)
 
Network and Tree in Graph Theory
Network and Tree in Graph TheoryNetwork and Tree in Graph Theory
Network and Tree in Graph Theory
 
Data structure
Data structureData structure
Data structure
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 

Minimum spanning tree

  • 1. D.STEFFY(140071601072) R.TASNIM TABASUM(140071601080) THIRD YEAR CSE-B ALGORITHM DESIGN AND ANALYSIS LAB(CSB 3105) B.S.ABDUR RAHMAN UNIVERSITY DONE BY: 1
  • 2.  Problem Identification  Definition Of Spanning Tree &Minimum Spanning Tree  Algorithms used and its design  Algorithm analysis  Scenario Explanation  Comparison between prim’s and Kruskal's algorithm  Properties of Minimum Spanning Tree 2
  • 3. 3
  • 4. PROBLEM IDENTIFICATION  A cable TV company is laying cable in a new neighborhood. There is a condition for them to bury the cable only along certain paths .  In those paths, some might be very expensive to bury the cable because they are longer, or require the cable to be buried deeper.  A minimum spanning tree is a spanning tree which has a minimum total cost. 4
  • 5. Definition : Spanning Tree & Minimum Spanning Tree  A spanning Tree of a connected graph G is its connected sub graph that contains all the vertices of the graph.  A Minimum Spanning Tree of a weighted connected graph G is its spanning tree of the smallest weight where the weight of the tree is defined as the sum of the weights on all its edges.  A Minimum Spanning Tree exists if and only if G is connected. 5
  • 6. 6
  • 7. Algorithms used To Find Minimum Spanning Tree There are two algorithms used to find the minimum spanning tree of a connected graph G. 7
  • 8. Prim’s Algorithm  Prim’s algorithm is one of the way to compute a minimum spanning tree.  Initially discovered in 1930 by Vojtěch Jarník, then rediscovered in 1957 by Robert C. Prim.  This algorithm begins with a set U initialized to{1}.It then grows a spanning tree , one edge at a time.  At each step , it finds a shortest edge (u ,v ) such that the cost of (u , v) is the smallest among all edges , where u is in Minimum Spanning Tree and V is not in Minimum Spanning Tree  Complexity:O(v2) 8
  • 9. Kruskal’s Algorithm Step 1: Sort all edges in non-decreasing order of their weight. Step 2: Pick the smallest edge. Step 3:Check if it forms a cycle with Spanning Tree formed so far. Step 4:If cycle is not formed , include this edge else discard it. Step 5:Repeat Union-Find algorithm until there are V-1 edges in the spanning tree. Complexity:O(ElogV) 9
  • 10. 10
  • 11. ALGORITHMS Two algorithms are used to find minimum spanning tree. 11
  • 12. 12
  • 13. PRIM’S ALGORITHM Place the starting node in the tree. Repeat until all nodes are in the tree are visited: Find all edges which is adjacent to source vertex. Of those edges, choose one with the minimum weight. Add that edge and the connected node to the tree. A B C 13 E
  • 14. ANALYSIS  Prim’s algorithm complexity varies based on the representation of the graph.  In adjacency matrix representation, prim’s algorithm requires O(V2) running time.  Because, in adjacency representation linearly searching an array of weights to find the minimum weight edge and to add that edge will require O(v2) running time. 14
  • 15. 15
  • 18. 18
  • 19. Problem : Laying TV Cable Central office 19
  • 20. Graph G Central office Expensive!!!! & cost:94 18 3 5 1 210 3 1 16 8 9 5 7 4 2A B C D E F G H V Know n dv Pv A 0 0 0 B 0 ∞ 0 C 0 ∞ 0 D 0 ∞ 0 E 0 ∞ 0 F 0 ∞ 0 G 0 ∞ 0 H 0 ∞ 0 CO 0 ∞ 0 20
  • 21. WHY PRIM’S ALGORITHM? Graph is a connected graph Since ,Graph which represents this scenario is looks like a dense graph. Prim’s algorithm works well in dense graphs. Prim’s algorithm complexity will be O(v2) 21
  • 22. Problem : Laying TV Cable->Step 1 Central office A B C D E F G H Source vertex 22
  • 23. Problem : Laying TV Cable->step 2 Central office A B C D E F G H 1 V Known dv Pv A 1 0 0 B 0 1 A C 0 ∞ 0 D 0 ∞ 0 E 0 ∞ 0 F 0 ∞ 0 G 0 ∞ 0 H 0 ∞ 0 CO 0 ∞ 0 23
  • 24. Problem : Laying TV Cable Central office A B C D E F G H 1 3 V Known dv Pv A 1 0 0 B 1 1 A C 0 3 B D 0 ∞ 0 E 0 ∞ 0 F 0 ∞ 0 G 0 ∞ 0 H 0 ∞ 0 CO 0 ∞ 0 24
  • 25. Problem : Laying TV Cable->step 3 Central office A B C D E F G H 1 3 5 V Known dv Pv A 1 0 0 B 1 1 A C 1 3 B D 0 5 c E 0 ∞ 0 F 0 ∞ 0 G 0 ∞ 0 H 0 ∞ 0 CO 0 ∞ 025
  • 26. Final step : Minimum Spanning Tree B C D E H G F Central office A Minimum Cost=24 1 4 3 3 1 5 2 5 V Known dv Pv A 1 0 0 B 1 1 A C 1 3 B D 1 5 C E 1 3 CO F 1 5 E G 1 2 F H 1 1 G CO 1 4 D 26
  • 27. 27
  • 28. COMPARISON PRIM’S ALGORITHM Initializes with node MST grows like a tree Graph must be a connected graph Time complexity is O(v2) Works well in dense graphs KRUSKAL’S ALGORITHM Initializes with an edge MST grows like a forest Works well in non connected graphs also. Time complexity is O(E log E) Works well in sparse graphs 28
  • 29. 29
  • 30. Properties Of Minimum Spanning Tree 1.Possible Multiplicity:  There may be several minimum spanning trees of the same weight having a minimum number of edges  If all the edge weights of a given graph are the same, then every spanning tree of that graph is minimum.  If there are n vertices in the graph, then each minimum spanning tree has n-1 edges. 30
  • 31. Example: Graph G Minimum spanning tree 1 Minimum spanning tree 2 31
  • 32. Continues…. 2.Uniqueness:  If each edge has a distinct weight then there will be only one, unique minimum spanning tree. 3.Cyclic property:  For any cycle C in the graph G , if the weight of an edge of e of c is larger than the individual weights of all other edges of c , then this edge cannot belong to MST. C 32
  • 33. Continues…. 4.Minimum Cost Edge: If the minimum cost edge e of a graph is unique, then this edge is included in any MST. 33
  • 34. 34

Editor's Notes

  1. 1
  2. 3
  3. 6
  4. 10
  5. 12
  6. 15
  7. 18
  8. 27
  9. 29