PRIM’S AND KRUSKAL’S ALGORITHM

JaydeepDesai10 583 views 16 slides Apr 12, 2020
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

It is Data-Structure


Slide Content

PRIM’S AND KRUSKAL’S ALGORITHM Gauri Bharat (24) Anushka Bhave (25) Dhairyashil Desai (37) Jaydeep Desai(38)

Content 01 Prim’s Algorithm 02 Application of Prim’s algorithm 03 Kruskal’s algorithm 04 Application of Kruskal’s Algorithm

Prim’s Algorithm

Basic terms 01 03 02 sub-graph of an undirected and a connected graph, which includes all the vertices of the graph having a minimum possible number of edges. Spanning tree Greedy Algorithm works by making the decision that seems most promising at any moment; it never reconsiders this decision, whatever situation may arise later. Greedy algorithm spanning tree in which the sum of the weight of the edges is as minimum as possible. Minimum spanning tree

Steps for prim’s Algorithm Choose a vertex and find shortest edge from it Mark this edge as visited and add to spanning tree Select another non visited edge with the minimum weight Repeat the process till we get spanning tree with all vertices

Prims Application Network design telephone, electrical, hydraulic, TV cable, computer, road

Google map network

Cluster Analysis

Kruskal’s Algorithm Minimum Spanning Tree Finds a subset of the   edges  that forms a tree that includes every  vertex , where the total weight of all the edges in the tree is minimized It is a greedy algorithm in graph theory

Applications of Kruskal’s Algorithm Reducing data storage (amino acids) Cluster analysis Network Design salesman Problems .

Kruskal’s algorithm applications On your trip to Venice, you plan to visit all the important world heritage sites but are short on time. To make your itinerary work, you decide to use Kruskal’s algorithm using disjoint sets

Kruskals algorithm Application Cannaregio Ponte Scalzi Santa Corce Dell ‘Orto Ferrovia Piazzale Roma San Polo Dorso Duro San Marco St. Mark Basilica Castello Arsenale A B C D E F G H I J K L B,C I,J B,E C,G G,I C,D K,L E,F A,B A,C 1 1 2 2 2 2 3 4 6 6 A,D E,C J,L F,H F,G H,I I,K D,J G,H H,K 6 7 8 10 11 12 16 18 22 25

Remove all loops and parallel edges So for the given map, we have a parallel edge running between Madonna dell’Orto (D) to St. Mark Basilica (J), which is of length 2.4kms(2400mts). We will remove the parallel road and keep the 1.8km (1800m) length for representation

Differences Prims algorithm It start to build MST from any node Selects shortest edge connected to that vertex Prims algorithm is faster for dense graphs Kruskal’s algorithm It start to build the MST from minimum weighted edge in the graph Selects next shortest edge which does not create any cycle Kruskal’s algorithm is faster for sparse graphs

Thank you
Tags