Dijkstra's Algorithm (cont)
Time complexity analysis …
Each edge needs to be considered once ⇒ O(E).
Outer loop has O(V) iterations.
Implementing "find s∈vSet with minimum dist[s] "
- try all
s ∈vSet ⇒ cost = O(V) ⇒ overall cost = O(E + V2) = O(V2)
- using a PQueue to implement extracting minimum
- can improve overall cost to O(E + V·log V)
(for best-known implementation)
|