Explanation

- **Dijkstra's Algorithm** is a greedy algorithm used to find the shortest paths from a source vertex to all other vertices in a **weighted graph** with **non-negative edge weights**.
-
  • Steps:

    • Initialize the distance to the source as 0 and all other distances as infinity.
    • Mark the source as visited and update the distances to its adjacent vertices.
    • Pick the unvisited vertex with the smallest tentative distance, mark it as visited, and update the distances to its neighbors.
    • Repeat until all vertices are visited.
  • Time Complexity:

    • O(V log V + E log V) with a priority queue.