Q. What data structure is commonly used to implement Dijkstra's algorithm efficiently?
-
A.
Array
-
B.
Linked List
-
C.
Priority Queue
-
D.
Stack
Solution
A priority queue is used in Dijkstra's algorithm to efficiently retrieve the next node with the smallest tentative distance.
Correct Answer:
C
— Priority Queue
Learn More →
Q. What is the output of Dijkstra's algorithm if the graph has multiple shortest paths?
-
A.
One of the shortest paths
-
B.
All shortest paths
-
C.
The longest path
-
D.
No path
Solution
Dijkstra's algorithm will return one of the shortest paths, but not necessarily all of them.
Correct Answer:
A
— One of the shortest paths
Learn More →
Q. Which algorithm can be used to find the shortest path in a graph with negative weights?
-
A.
Dijkstra's Algorithm
-
B.
Bellman-Ford Algorithm
-
C.
A* Search Algorithm
-
D.
Floyd-Warshall Algorithm
Solution
The Bellman-Ford algorithm can handle graphs with negative weights and can also detect negative cycles.
Correct Answer:
B
— Bellman-Ford Algorithm
Learn More →
Showing 1 to 3 of 3 (1 Pages)