SlideShare a Scribd company logo
1
4
9
6
3
7
5
2
0
8
Dijkstra’s
Algorithm & Prim’s
Algorithm
Understanding the Fundamentals of Shortest Path and
Minimum Spanning Tree
Our Team
• Seerat Fatima [2024-DS-32]
• Aleena Ahmad [2024-DS-9]
• Minahil Samreen [2024-DS-11]
• Amna Naveed [2024-DS-42]
1
3
4 9
7
5
2
0
6
8
Today’s Agenda
1
3
8
9
7
5
0
6
2
Dijestra’s
Algorithm
01
Prim’s
Algorithm
03
Real
World
Example
02
Real
World
Example
04
1
4
9
6
3
7
5
2
0
8
Dijkstra
Algorithm
What is Dijkstra's Algorithm?
• Dijkstra's algorithm finds the shortest path from one
vertex to all other vertices.
• It does so by repeatedly selecting the nearest unvisited
vertex and calculating the distance to all the unvisited
neighboring vertices.
How it works?
• Start from the source
node.
• Assign initial distances
(infinity except for the
source = 0).
• Visit neighbors of the
current node, update
shortest paths.
• Repeat until all nodes
are visited.
Example Problem
A
D
B
C
E
6
1
5
5
1 2
2
Answer
A = 0
B = 1+2=3 (A -> D -> B)
C = 1+1+5=7 (A -> D -> E -> C)
D = 1 (A -> D)
E = 1+1=2 (A -> D -> E)
• GPS navigation systems
• Network routing protocols
• Game AI pathfinding
Where is it used?
1
3
8
9
7
5
0
6
2
1
4
9
6
3
7
5
2
0
8
Real World
Example
Finding the shortest route from Lahore to all other
cities
Lahor
e
Karach
i
Islamaba
d
Multa
n
Peshawa
r
Quett
a
Solution
1.A = 0
2.B = 4 (A -> B)
3.C = 5 (A -> C)
4.D = 4 + 9 = 13 (A -> B -> D)
5.E = 5 + 3 = 8 (A -> C -> E)
6.F = 5 + 3 + 6 = 14 (A -> C -> E -> F)
1
4
9
6
3
7
5
2
0
8
Prim’s
Algorithm
What is Prim's Algorithm?
• Prim's algorithm finds the Minimum Spanning Tree
(MST) in a connected and undirected graph.
• The MST found by Prim's algorithm is the collection of
edges in a graph, that connects all vertices,with a
minimum sum of edge weights.
1
3
6
8
9
7
5
2
0 Fundamental Concepts
A spanning tree is a subgraph of a connected, undirected
graph that includes all the vertices of the graph and is a tree
(i.e., it has no cycles).
Spanning tree
A spanning tree is a subgraph of a connected, undirected
graph that includes all the vertices of the graph and is a tree
(i.e., it has no cycles).
Minimum Spanning
tree
How it works?
• Start with any node.
• Add the smallest edge that
connects an unvisited node.
• Repeat until all nodes are
connected.
Example Problem
Cost of MST = 4 + 2 + 1 + 3 = 10 units.vv
Answer
Cost of MST = 4 + 2 + 1 + 3 = 10 units.
• Network design
• Clustering analysis
• Circuit Design
Where is it used?
1
3
8
9
7
5
0
6
2
1
4
9
6
3
7
5
2
0
8
Real World
Example
Designing a minimum-cost communications
network
Solution
Solution
Its Quiz Time!!!!
Let's see how much you've learned so far!
1
3
4 9
7
5
2
0
6
8
8
1
4
9
6
3
7
5
2
0
Thank
you!
Ad

Recommended

Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
Shouvic Banik0139
 
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
Shouvic Banik0139
 
Greedy technique - Algorithm design techniques using data structures
Greedy technique - Algorithm design techniques using data structures
divyammo
 
3 Greedy-lec.pptggggghhhhhhhyyyyyyyyyyyyyy
3 Greedy-lec.pptggggghhhhhhhyyyyyyyyyyyyyy
esraelman182
 
Single source Shortest path algorithm with example
Single source Shortest path algorithm with example
VINITACHAUHAN21
 
Lecture-12-CS345A-2023 of Design and Analysis
Lecture-12-CS345A-2023 of Design and Analysis
ssuser9183b6
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
KUSHDHIRRA2111026030
 
Ram minimum spanning tree
Ram minimum spanning tree
Rama Prasath A
 
Greedy algorithm pptxe file for computer
Greedy algorithm pptxe file for computer
kerimu1235
 
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
DKTaxation
 
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
bharatherltech
 
Unit3_1.pdf
Unit3_1.pdf
Pratimakumari213460
 
Algo labpresentation a_group
Algo labpresentation a_group
Umme habiba
 
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
ABIRAMIS87
 
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
 
09 placement
09 placement
yogiramesh89
 
36 greedy
36 greedy
Ikram Khan
 
dms slide discrete mathematics sem 2 engineering
dms slide discrete mathematics sem 2 engineering
pranavstar99
 
A greedy algorithms
A greedy algorithms
Amit Kumar Rathi
 
Network flow
Network flow
Ahmed Sobhi
 
(148065320) dijistra algo
(148065320) dijistra algo
Aravindharamanan S
 
Algorithm chapter 9
Algorithm chapter 9
chidabdu
 
Greedy
Greedy
minhaz uddin
 
_A C program for Prim's Minimum Spanning Tree (MST) algorithm. The program is...
_A C program for Prim's Minimum Spanning Tree (MST) algorithm. The program is...
SatyamMishra828076
 
Cryptography using rsa cryptosystem
Cryptography using rsa cryptosystem
Samdish Arora
 
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
OrxanMirzzad
 
1 sollins algorithm
1 sollins algorithm
Muhammad Salman
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
Saad Liaqat
 
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
RAKESH SAJJAN
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 

More Related Content

Similar to Discrete Mathematics ( Dijkstra Algorithm & Prims Algorithm) (20)

Greedy algorithm pptxe file for computer
Greedy algorithm pptxe file for computer
kerimu1235
 
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
DKTaxation
 
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
bharatherltech
 
Unit3_1.pdf
Unit3_1.pdf
Pratimakumari213460
 
Algo labpresentation a_group
Algo labpresentation a_group
Umme habiba
 
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
ABIRAMIS87
 
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
 
09 placement
09 placement
yogiramesh89
 
36 greedy
36 greedy
Ikram Khan
 
dms slide discrete mathematics sem 2 engineering
dms slide discrete mathematics sem 2 engineering
pranavstar99
 
A greedy algorithms
A greedy algorithms
Amit Kumar Rathi
 
Network flow
Network flow
Ahmed Sobhi
 
(148065320) dijistra algo
(148065320) dijistra algo
Aravindharamanan S
 
Algorithm chapter 9
Algorithm chapter 9
chidabdu
 
Greedy
Greedy
minhaz uddin
 
_A C program for Prim's Minimum Spanning Tree (MST) algorithm. The program is...
_A C program for Prim's Minimum Spanning Tree (MST) algorithm. The program is...
SatyamMishra828076
 
Cryptography using rsa cryptosystem
Cryptography using rsa cryptosystem
Samdish Arora
 
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
OrxanMirzzad
 
1 sollins algorithm
1 sollins algorithm
Muhammad Salman
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
Saad Liaqat
 
Greedy algorithm pptxe file for computer
Greedy algorithm pptxe file for computer
kerimu1235
 
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
DKTaxation
 
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
bharatherltech
 
Algo labpresentation a_group
Algo labpresentation a_group
Umme habiba
 
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
DATA STRUCTURE AND ALGORITHM LMS MST KRUSKAL'S ALGORITHM
ABIRAMIS87
 
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
 
dms slide discrete mathematics sem 2 engineering
dms slide discrete mathematics sem 2 engineering
pranavstar99
 
Algorithm chapter 9
Algorithm chapter 9
chidabdu
 
_A C program for Prim's Minimum Spanning Tree (MST) algorithm. The program is...
_A C program for Prim's Minimum Spanning Tree (MST) algorithm. The program is...
SatyamMishra828076
 
Cryptography using rsa cryptosystem
Cryptography using rsa cryptosystem
Samdish Arora
 
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
OrxanMirzzad
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
Saad Liaqat
 

Recently uploaded (20)

Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
RAKESH SAJJAN
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
RAKESH SAJJAN
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Health Care Planning and Organization of Health Care at Various Levels – Unit...
Health Care Planning and Organization of Health Care at Various Levels – Unit...
RAKESH SAJJAN
 
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
RAKESH SAJJAN
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
 
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
RAKESH SAJJAN
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
Assisting Individuals and Families to Promote and Maintain Health – Unit 7 | ...
RAKESH SAJJAN
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
RAKESH SAJJAN
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Health Care Planning and Organization of Health Care at Various Levels – Unit...
Health Care Planning and Organization of Health Care at Various Levels – Unit...
RAKESH SAJJAN
 
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
Environmental Science, Environmental Health, and Sanitation – Unit 3 | B.Sc N...
RAKESH SAJJAN
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
LDM Recording Presents Yogi Goddess by LDMMIA
LDM Recording Presents Yogi Goddess by LDMMIA
LDM & Mia eStudios
 
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs – Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
 
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
RAKESH SAJJAN
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
LAZY SUNDAY QUIZ "A GENERAL QUIZ" JUNE 2025 SMC QUIZ CLUB, SILCHAR MEDICAL CO...
Ultimatewinner0342
 
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDMMIA Practitioner Student Reiki Yoga S2 Video PDF Without Yogi Goddess
LDM & Mia eStudios
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
Q1_ENGLISH_PPT_WEEK 1 power point grade 3 Quarter 1 week 1
jutaydeonne
 
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
ENGLISH_Q1_W1 PowerPoint grade 3 quarter 1 week 1
jutaydeonne
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
Ad

Discrete Mathematics ( Dijkstra Algorithm & Prims Algorithm)