[prev] 66 [next]

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]"

  1. try all svSet ⇒ cost = O(V) ⇒ overall cost = O(E + V2) = O(V2)
  2. using a PQueue to implement extracting minimum
    • can improve overall cost to O(E + V·log V)   (for best-known implementation)