Shortest Path Algorithms (Dijkstra's Algorithm) Flashcards
(4 cards)
1
Q
What is Dijkstra’s Algorithm used for?
A
To find the shortest path from a source vertex to all other vertices in a graph with non-negative weights.
2
Q
How does Dijkstra’s Algorithm work?
A
Uses a priority queue to pick the node with the shortest tentative distance and updates its neighbors accordingly.
3
Q
What is the time complexity of Dijkstra’s Algorithm?
A
O((V + E) log V) using a min-priority queue.
4
Q
Can Dijkstra’s Algorithm handle negative weights?
A
No — it assumes that once a node’s shortest path is found, it won’t be improved.