09.07.2015 Views

Dijkstra's shortest path algorithm • This algorithm is a “greedy” one ...

Dijkstra's shortest path algorithm • This algorithm is a “greedy” one ...

Dijkstra's shortest path algorithm • This algorithm is a “greedy” one ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Ultimate effect on complexity of DIJKSTRA• Let G = (V, E).• EXTRACT-MIN takes O(log |V |) time, and there are |V | such operations.• Building the heap in the first place takes O(|V |).• Can do the step of setting vertices v /∈ S with an edge to the current u tomin{L(v), L(u) + w(u, v)}, in O(|E| log |V |) (not shown).• Total time <strong>is</strong> then O(|E| log |V |). Thus if the graph <strong>is</strong> sparse (say a constantnumber of edges per node, so |E| = O(|V |), we can get the time down toO(|V | log |V |).11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!