19IS303 – DATA STRUCTURES
AND ALGORITHMS
UNIT 4
RECAP
• Introduction to graphs
• Types of graphs
• Graph Traversals
– BFT
– DFT
• Topological sorting
Dijkstra Algorithm
• Dijkstra algorithm is a greedy algorithm.
• It finds a shortest path tree for a given weighted graph.
• This means it finds a shortest paths between nodes in a graph,
which may represent, for example, road networks
• For a given source node in the graph, the algorithm finds the
shortest path between source node and every other node.
• This algorithm also used for finding the shortest paths from a
single node to a single destination node by stopping the
algorithm once the shortest path to the destination node has
been determined.
Example
• Find the shortest path from A to Z:
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Apply the steps of the Dijkstra’s Algorithm to
find the shortest path from A to Z using the
following graph:
Apply the steps of the Dijkstra’s Algorithm to
find the shortest path from A to Z using the
following graph:
• Visualization Link:
https://www.101computing.net/dijkstras-
shortest-path-algorithm/

19IS303_22-23_LM11.pdf