Q. What happens if Dijkstra's algorithm is run on a graph with a negative weight cycle?
A.
It will return the correct shortest path
B.
It will enter an infinite loop
C.
It will terminate with an error
D.
It may return incorrect results
Solution
If Dijkstra's algorithm is run on a graph with a negative weight cycle, it may return incorrect results, as the algorithm assumes that once a vertex's shortest path is found, it will not change.
Correct Answer:
D
— It may return incorrect results
Q. Which of the following data structures is most efficient for implementing Dijkstra's algorithm?
A.
Array
B.
Linked List
C.
Binary Heap
D.
Stack
Solution
A binary heap is the most efficient data structure for implementing Dijkstra's algorithm, as it allows for efficient extraction of the minimum element and updates of the priority queue.