I've been trying to understand the internals of the Dijkstra's Algorithm to find the shortest path for the weighted graph.
After visiting one vertex, why we have to store the adjacent vertex's into a PriorityQueue instead of normal Queue ?
The reason I'm asking the above question was : I understand with PriorityQueue we can get either biggest / smallest numbers from the Queue. But in the case of Dijkstra's Algorithm, we are anyway visiting all the vertex's irrespective of distance / priority. In such cases why do we need to use PriorityQueue with O(log N) complexity, where normal Queue would do O(1) ?
Am I missing anything ?