Algorithms and Data Structures · Middle · Question 59 of 75
Which data structure makes Dijkstra's algorithm efficient?
- ✓Correct answer: A priority queue (min-heap)
- 2A stack of unvisited vertices
- 3A plain FIFO queue of vertices
Explanation
The heap gives the closest unvisited vertex in O(log V). With a plain queue the algorithm becomes BFS, which ignores weights; scanning all vertices for the minimum makes it O(V²).