A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
Greedy Algorithm-Dijkstra's algo
1. Analysis and Design of Algorithms
(2150703)
Presented by :
Jay Patel (130110107036)
Gujarat Technological University
G.H Patel College of Engineering and Technology
Department of Computer Engineering
Greedy Algorithms
Guided by:
Namrta Dave
2. Dijkstra's Algorithm:
dist[s] ←0 (distance to source vertex is zero)
for all v ∈ V–{s}
do dist[v] ←∞ (set all other distances to infinity)
S←∅ (S, the set of visited vertices is initially empty)
Q←V (Q, the queue initially contains all vertices)
while Q ≠∅ (while the queue is not empty)
do u ← mindistance(Q,dist) (select the element of Q with the min. distance)
S←S∪{u} (add u to list of visited vertices)
for all v ∈ neighbors[u]
do if dist[v] > dist[u] + w(u, v) (if new shortest path found)
then d[v] ←d[u] + w(u, v) (set new value of shortest path)
(if desired, add traceback code)
return dist
6. 9
11
10
1
2
6
2
4
21
3
4
2
3
2
0
3
2
3
6
4
5
6
4
d(6) is not updated
1
2
2
4
21
3
4
2
3
2
0
3
2
3
6
4
5
6
4
6
There is nothing to update
1
2
2
4
21
3
4
2
3
2
0
3
2
3
6
4
5
6
4
6
All nodes are now permanent
The predecessors form a tree
The shortest path from node 1 to node 6 can be found by
tracing back predecessors
7. There are some methods left:
• Huffman’s Algorithm
• Task scheduling
• Travelling salesman Problem etc.
• Dynamic Greedy Problems
Greedy Algorithms:
We can find the optimized solution with Greedy method which may be optimal sometime.