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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the time complexity of Dijkstra’s Algorithm?

A

O((V + E) log V) using a min-priority queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly