Q. What is the time complexity of Dijkstra's algorithm when using a priority queue implemented with a binary heap?
-
A.
O(V^2)
-
B.
O(E log V)
-
C.
O(V log V)
-
D.
O(E + V)
Solution
The time complexity of Dijkstra's algorithm using a binary heap is O(E log V), where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. What will happen if Dijkstra's algorithm is run on a graph with negative weight edges?
-
A.
It will still find the shortest path.
-
B.
It may produce incorrect results.
-
C.
It will terminate with an error.
-
D.
It will only work for the first negative edge.
Solution
Dijkstra's algorithm may produce incorrect results if there are negative weight edges in the graph.
Correct Answer:
B
— It may produce incorrect results.
Learn More →
Showing 1 to 2 of 2 (1 Pages)