Dijkstra's Algorithm Flashcards

1
Q

What is Dijkstra’s algorithm?

A

it is an algorithm used to find the shortest path between a node and all other nodes in a graph

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

What is the space complexity of Dijkstra’s algorithm?

A

O(V^2) when using an adjacency matrix
O(V + E) when using an adjacency list

Where V is the number of vertices

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

What is the limitation of Dijkstra’s algorithm?

A

It assumes that the edges in the graph have nonnegative weights, if edges have negative weights Djiktra’s algorithm might pre-maturely determine the wrong shortest path, concluding that a longer path is shorter due to a negative weight. For graphs with negative edge weights, the suitable algorithm to use will be the Bellman-Ford algorithm

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

What is the time complexity of Djiktra’s algorithm?

A

O(V^2) when using an adjacency matrix
O(V + E) when using an adjacency list

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