SlideShare a Scribd company logo
Data Structure & Algorithm
ICT-5102
Homework Assignment 2
To Honorable:
Dr. Hussain Asiful Mustafa
Assistant Professor
IICT-BUET.
Submitted By:
Md.Dedarul Hasan
Reg.Id: 0417311011
PGD in IT, IICT-BUET.
4/9/2019
IICT, BUET
TO FIND THE LONGEST PATH FOR THAT GRAPH BY DIJKSTRA ALGORITHM
Distance (A)=0
Source=’A’
Fig : 1 .given graph for longest path find
Dijkstra’s algorithm to find the Longest path between A and B. It picks the unvisited vertex with the
lowest distance, calculates the distance through it to each unvisited neighbor and updates the neighbors
distance if smaller. Mark visited when done with neighbors.
But for that requirement of Dijkstra’s algorithm to find out the longest path we will find pick the
unvisited vertex with the highest distance & calculate the distance through it to each unvisited neighbor &
updates the neighbors distance if greater. Mark visited when done with the neighbors.
Modification of that graph by Dijkstra Algorithm- step by step for longest path:
 First Source ‘A’ is ‘0’ & others vertex is ∞
 We have picked highest distance for unvisited vertex & calculated through it to each unvisited neighbor
and updated the neighbor distance for greater.
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
∞∞
∞
∞
∞
ALGORITHM FOR THAT GRAPH TO FIND LONGEST PATH
STEP1:
Distance(B)=6
Distance(C)=5
Fig: 2Pick vertex in List with maximum distance, i.e., B
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
56
∞
∞
∞
STEP2:
Distance(C)=6+5=11
Fig: 3
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
116
3
∞
2
STEP3:
Distance(F)=11+3=14
Distance(D)=11+2=13
Fig: 4
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
116
3
13
14
STEP4:
Distance(E)=14+3=17
Distance(D)=14+1=15
Fig :5
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
116
17
15
14
STEP5:
Distance(D)=17+4=21
Fig: 6
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
116
17
21
14
STEP6:
Longest Path Cost is= 6+11+14+17+21=69
Fig: 7
A
F
CB
DE
56
2
3
2
5
3
3 1
4
0
116
17
21
14
STEP7:
The Final Graph for longest path
Fig: 7 –Longest Path Final for the graph G(V,E)
A
B
F
E D
C
0
116
14
21
17
PSEUDOCODES FOR THAT LONGEST PATH USING DIJKSTRA’S ALGORITHM
Dijkstra():
for each vertex v:
v's distance:=infinity.
v's previous:=none.
v1's distance:=0.
List:={all vertics}
while List is not empty:
v:=remove List vertex with MAXIMUM distance.
Mark v as known.
for each unknown neighbor n of v:
dist:=v's distance+edge(v,n)'s weight.
if dist is GREATER than n's distance:
n's distance:=dist.
n's previous:=v.
Reconstruct path from v2 back to v1, following previous pointers.
IMPLEMENTATIONS CODE
We have assigned that graph which has to be converted as a tree node structure: [input array]
From Step 1-7:
A B C D E F
A 0 6 5 0 0 0
B 0 0 5 0 3 2
C 0 5 0 2 0 3
D 0 0 0 0 0 1
E 0 0 0 4 0 0
F 0 0 0 0 3 0
Programming Code Using c :
EXECUTION OF PROGRAM IMPLEMENTATION & OUTPUT GRAPH WHERE SOURCE IS ‘A’
Output:
RESULT as Graph
METARIALS
CodeBlocks
Sublime Text Editor
Ms Word To Draw Graph
CONCLUSION
Total Longest Path Graph is: A B C F E D
REFERENCE
Class Lectures
Stack Overflow
Dynamic Programming For Longest Path Solution Sequence
A
B
F
E D
C

More Related Content

What's hot

Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
faisal2204
 
d
dd
6 Hiclus
6 Hiclus6 Hiclus
Perimeter 1
Perimeter 1Perimeter 1
Perimeter 1
guest7815b7d
 
11.3 Distance Midpoint Formulas
11.3 Distance Midpoint Formulas11.3 Distance Midpoint Formulas
11.3 Distance Midpoint Formulas
Jessca Lundin
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
taimurkhan803
 
Homework1
Homework1Homework1
Homework1
mohamed Eraky
 
6 Concor
6 Concor6 Concor
Metodo de bairstow
Metodo de bairstowMetodo de bairstow
Metodo de bairstow
Juan Tovare
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
Rashik Ishrak Nahian
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
STEFFY D
 
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)
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
Salman Elahi
 
Hamilton Path & Dijkstra's Algorithm
Hamilton Path & Dijkstra's AlgorithmHamilton Path & Dijkstra's Algorithm
Hamilton Path & Dijkstra's Algorithm
Mahesh Singh Madai
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
sakthibalabalamuruga
 
Vectors mod-1-part-1
Vectors mod-1-part-1Vectors mod-1-part-1
Vectors mod-1-part-1
Asmita Bhagdikar
 
linear Algebra least squares
linear Algebra least squareslinear Algebra least squares
linear Algebra least squares
Noreen14
 
Least Squares method
Least Squares methodLeast Squares method
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
Srikrishnan Suresh
 

What's hot (19)

Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
 
d
dd
d
 
6 Hiclus
6 Hiclus6 Hiclus
6 Hiclus
 
Perimeter 1
Perimeter 1Perimeter 1
Perimeter 1
 
11.3 Distance Midpoint Formulas
11.3 Distance Midpoint Formulas11.3 Distance Midpoint Formulas
11.3 Distance Midpoint Formulas
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Homework1
Homework1Homework1
Homework1
 
6 Concor
6 Concor6 Concor
6 Concor
 
Metodo de bairstow
Metodo de bairstowMetodo de bairstow
Metodo de bairstow
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
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)
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
 
Hamilton Path & Dijkstra's Algorithm
Hamilton Path & Dijkstra's AlgorithmHamilton Path & Dijkstra's Algorithm
Hamilton Path & Dijkstra's Algorithm
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
 
Vectors mod-1-part-1
Vectors mod-1-part-1Vectors mod-1-part-1
Vectors mod-1-part-1
 
linear Algebra least squares
linear Algebra least squareslinear Algebra least squares
linear Algebra least squares
 
Least Squares method
Least Squares methodLeast Squares method
Least Squares method
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 

Similar to Assignment homework 2

Dijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithmDijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithm
Delowar Hossain
 
Dijesktra 1.ppt
Dijesktra 1.pptDijesktra 1.ppt
Dijesktra 1.ppt
DEEPAK948083
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
Khoa Mac Tu
 
routing algorithm
routing algorithmrouting algorithm
routing algorithm
AnusuaBasu
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
Subid Biswas
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
A. S. M. Shafi
 
routing alg.pptx
routing alg.pptxrouting alg.pptx
routing alg.pptx
Acad
 
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithmAAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
SantoshDood
 
Jaimin chp-5 - network layer- 2011 batch
Jaimin   chp-5 - network layer- 2011 batchJaimin   chp-5 - network layer- 2011 batch
Jaimin chp-5 - network layer- 2011 batch
Jaimin Jani
 
Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptx
DrYogeshDeshmukh1
 
shortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfshortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdf
zefergaming
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
Ruchika Sinha
 
Shortest path analysis
Shortest path analysis Shortest path analysis
Shortest path analysis
A K M Anwaruzzaman
 
IAP PPT-1.pptx
IAP PPT-1.pptxIAP PPT-1.pptx
IAP PPT-1.pptx
HirazNor
 
IAP presentation-1.pptx
IAP presentation-1.pptxIAP presentation-1.pptx
IAP presentation-1.pptx
HirazNor
 
Geopy module in python
Geopy module in pythonGeopy module in python
Geopy module in python
Ashmita Dhakal
 
Comparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State ProtocolsComparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State Protocols
East West University
 
Digital Distance Geometry
Digital Distance GeometryDigital Distance Geometry
Digital Distance Geometry
ppd1961
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
Monika Choudhery
 
ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...
ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...
ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...
IJCNCJournal
 

Similar to Assignment homework 2 (20)

Dijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithmDijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithm
 
Dijesktra 1.ppt
Dijesktra 1.pptDijesktra 1.ppt
Dijesktra 1.ppt
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
 
routing algorithm
routing algorithmrouting algorithm
routing algorithm
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
routing alg.pptx
routing alg.pptxrouting alg.pptx
routing alg.pptx
 
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithmAAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
 
Jaimin chp-5 - network layer- 2011 batch
Jaimin   chp-5 - network layer- 2011 batchJaimin   chp-5 - network layer- 2011 batch
Jaimin chp-5 - network layer- 2011 batch
 
Unit 3 Informed Search Strategies.pptx
Unit  3 Informed Search Strategies.pptxUnit  3 Informed Search Strategies.pptx
Unit 3 Informed Search Strategies.pptx
 
shortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfshortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdf
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
Shortest path analysis
Shortest path analysis Shortest path analysis
Shortest path analysis
 
IAP PPT-1.pptx
IAP PPT-1.pptxIAP PPT-1.pptx
IAP PPT-1.pptx
 
IAP presentation-1.pptx
IAP presentation-1.pptxIAP presentation-1.pptx
IAP presentation-1.pptx
 
Geopy module in python
Geopy module in pythonGeopy module in python
Geopy module in python
 
Comparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State ProtocolsComparative Analysis of Distance Vector Routing & Link State Protocols
Comparative Analysis of Distance Vector Routing & Link State Protocols
 
Digital Distance Geometry
Digital Distance GeometryDigital Distance Geometry
Digital Distance Geometry
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
 
ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...
ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...
ENHANCEMENT OF TRANSMISSION RANGE ASSIGNMENT FOR CLUSTERED WIRELESS SENSOR NE...
 

More from LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.

লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALLলালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALLলালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ ৩৬ নং আইন, ২০২৩,
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ  ৩৬ নং আইন, ২০২৩, ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ  ৩৬ নং আইন, ২০২৩,
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ ৩৬ নং আইন, ২০২৩,
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdfThe Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
DIGITAL COMMERCE LAWS & RULES 2021.docx
DIGITAL COMMERCE LAWS & RULES 2021.docxDIGITAL COMMERCE LAWS & RULES 2021.docx
Programming Your Home Automate with Arduino, Android, and Your Computer.pdf
Programming Your Home Automate with Arduino, Android, and Your Computer.pdfProgramming Your Home Automate with Arduino, Android, and Your Computer.pdf
Programming Your Home Automate with Arduino, Android, and Your Computer.pdf
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
Microcontroller.pdf
Microcontroller.pdfMicrocontroller.pdf
Digital_electronics_dynamic.pdf
Digital_electronics_dynamic.pdfDigital_electronics_dynamic.pdf
Project Electronics_Copy.pdf
Project Electronics_Copy.pdfProject Electronics_Copy.pdf
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docxবিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docxসুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 

More from LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD. (20)

লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALLলালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
লালমনিরহাট ৩ আসনের ভোট কেন্দ্র সমুহ - LALMONIRHAT 3 SADAR VOTE CENTER ALL
 
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALLলালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
লালমনিরহাট ৩ আসনের ওয়ার্ড সমূহ - LALMONIRHAT 3 WARD LIST ALL
 
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ ৩৬ নং আইন, ২০২৩,
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ  ৩৬ নং আইন, ২০২৩, ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ  ৩৬ নং আইন, ২০২৩,
ভূমি সংশ্লিষ্ট অপরাধ প্রতিকার ও প্রতিরোধ ৩৬ নং আইন, ২০২৩,
 
CrPC BARE ACT -1898 BANGLA.pdf
CrPC BARE ACT -1898  BANGLA.pdfCrPC BARE ACT -1898  BANGLA.pdf
CrPC BARE ACT -1898 BANGLA.pdf
 
CPC BARE ACT -1908 BANGLA.pdf
CPC BARE ACT -1908  BANGLA.pdfCPC BARE ACT -1908  BANGLA.pdf
CPC BARE ACT -1908 BANGLA.pdf
 
PC BARE ACT -1860 BANGLA.pdf
PC BARE ACT -1860  BANGLA.pdfPC BARE ACT -1860  BANGLA.pdf
PC BARE ACT -1860 BANGLA.pdf
 
SR BARE ACT -1877 BANGLA.pdf
SR BARE ACT -1877  BANGLA.pdfSR BARE ACT -1877  BANGLA.pdf
SR BARE ACT -1877 BANGLA.pdf
 
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdfThe Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
The Bangladesh Legal Practitioner_s and Bar Council Order, 1972.pdf
 
LA BARE ACT -1908 BANGLA.pdf
LA BARE ACT -1908  BANGLA.pdfLA BARE ACT -1908  BANGLA.pdf
LA BARE ACT -1908 BANGLA.pdf
 
EA BARE ACT -1872 BANGLA.pdf
EA BARE ACT -1872  BANGLA.pdfEA BARE ACT -1872  BANGLA.pdf
EA BARE ACT -1872 BANGLA.pdf
 
DIGITAL COMMERCE LAWS & RULES 2021.docx
DIGITAL COMMERCE LAWS & RULES 2021.docxDIGITAL COMMERCE LAWS & RULES 2021.docx
DIGITAL COMMERCE LAWS & RULES 2021.docx
 
Programming Your Home Automate with Arduino, Android, and Your Computer.pdf
Programming Your Home Automate with Arduino, Android, and Your Computer.pdfProgramming Your Home Automate with Arduino, Android, and Your Computer.pdf
Programming Your Home Automate with Arduino, Android, and Your Computer.pdf
 
Web site Review & Description by tanbircox.pdf
Web site Review & Description by tanbircox.pdfWeb site Review & Description by tanbircox.pdf
Web site Review & Description by tanbircox.pdf
 
Basic Electronics.pdf
Basic Electronics.pdfBasic Electronics.pdf
Basic Electronics.pdf
 
Circuit book_PP.pdf
Circuit book_PP.pdfCircuit book_PP.pdf
Circuit book_PP.pdf
 
Microcontroller.pdf
Microcontroller.pdfMicrocontroller.pdf
Microcontroller.pdf
 
Digital_electronics_dynamic.pdf
Digital_electronics_dynamic.pdfDigital_electronics_dynamic.pdf
Digital_electronics_dynamic.pdf
 
Project Electronics_Copy.pdf
Project Electronics_Copy.pdfProject Electronics_Copy.pdf
Project Electronics_Copy.pdf
 
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docxবিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
বিবিসি রুলেস ও অরডার, ১৯৭২ বেয়ার এক্ট -BBC BARE ACT.docx
 
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docxসুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
সুঃ প্রতিকার আইন ১৮৭৭ নোট.docx
 

Recently uploaded

Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 

Recently uploaded (20)

Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 

Assignment homework 2

  • 1. Data Structure & Algorithm ICT-5102 Homework Assignment 2 To Honorable: Dr. Hussain Asiful Mustafa Assistant Professor IICT-BUET. Submitted By: Md.Dedarul Hasan Reg.Id: 0417311011 PGD in IT, IICT-BUET. 4/9/2019 IICT, BUET
  • 2. TO FIND THE LONGEST PATH FOR THAT GRAPH BY DIJKSTRA ALGORITHM Distance (A)=0 Source=’A’ Fig : 1 .given graph for longest path find Dijkstra’s algorithm to find the Longest path between A and B. It picks the unvisited vertex with the lowest distance, calculates the distance through it to each unvisited neighbor and updates the neighbors distance if smaller. Mark visited when done with neighbors. But for that requirement of Dijkstra’s algorithm to find out the longest path we will find pick the unvisited vertex with the highest distance & calculate the distance through it to each unvisited neighbor & updates the neighbors distance if greater. Mark visited when done with the neighbors. Modification of that graph by Dijkstra Algorithm- step by step for longest path:  First Source ‘A’ is ‘0’ & others vertex is ∞  We have picked highest distance for unvisited vertex & calculated through it to each unvisited neighbor and updated the neighbor distance for greater. A F CB DE 56 2 3 2 5 3 3 1 4 0 ∞∞ ∞ ∞ ∞
  • 3. ALGORITHM FOR THAT GRAPH TO FIND LONGEST PATH STEP1: Distance(B)=6 Distance(C)=5 Fig: 2Pick vertex in List with maximum distance, i.e., B A F CB DE 56 2 3 2 5 3 3 1 4 0 56 ∞ ∞ ∞
  • 8. STEP6: Longest Path Cost is= 6+11+14+17+21=69 Fig: 7 A F CB DE 56 2 3 2 5 3 3 1 4 0 116 17 21 14
  • 9. STEP7: The Final Graph for longest path Fig: 7 –Longest Path Final for the graph G(V,E) A B F E D C 0 116 14 21 17
  • 10. PSEUDOCODES FOR THAT LONGEST PATH USING DIJKSTRA’S ALGORITHM Dijkstra(): for each vertex v: v's distance:=infinity. v's previous:=none. v1's distance:=0. List:={all vertics} while List is not empty: v:=remove List vertex with MAXIMUM distance. Mark v as known. for each unknown neighbor n of v: dist:=v's distance+edge(v,n)'s weight. if dist is GREATER than n's distance: n's distance:=dist. n's previous:=v. Reconstruct path from v2 back to v1, following previous pointers.
  • 11. IMPLEMENTATIONS CODE We have assigned that graph which has to be converted as a tree node structure: [input array] From Step 1-7: A B C D E F A 0 6 5 0 0 0 B 0 0 5 0 3 2 C 0 5 0 2 0 3 D 0 0 0 0 0 1 E 0 0 0 4 0 0 F 0 0 0 0 3 0 Programming Code Using c :
  • 12. EXECUTION OF PROGRAM IMPLEMENTATION & OUTPUT GRAPH WHERE SOURCE IS ‘A’ Output:
  • 13. RESULT as Graph METARIALS CodeBlocks Sublime Text Editor Ms Word To Draw Graph CONCLUSION Total Longest Path Graph is: A B C F E D REFERENCE Class Lectures Stack Overflow Dynamic Programming For Longest Path Solution Sequence A B F E D C