35-DijkstrasAlg

# 2b adjust distances in d for unsettled nodes o m log

• Notes
• 15

This preview shows page 13 - 15 out of 15 pages.

2b. adjust distances in D for unsettled nodes. { O( m log n ) dominates D(x) 0 a (b,5) (c,2) (d,1) 5 b (a,5) (c,2) 2 c (a,2) (b,2) (d,10) (e,1) 1 d (a,1) (b,10) (e,1) e (d,1) (c,1) Adjacency List: Over all iterations, the k ’s add up to 2( m - # of edges in the initialization).

Subscribe to view the full document.

Discussion #35 Chapter 7, Section 5.5 14/15 POT Construction/Manipulation b c a e d 5 2 2 1 10 1 1 (b,5) (b,5) (c,2) (c,2) (b,5) (c,2) (b,5) (d,1) (d,1) (b,5) (c,2) (d,1) (b,5) (c,2) (e, ) POT construction (start = a) Find smallest always on top; then swap and bubble down (d,1) (b,5) (c,2) (e, ) (e, ) (b,5) (c,2) (d,1) (c,2) (b,5) (e, ) (c,2) (b,5) (e,2) Adjust distances POT doubly linked to adjacency list nodes bubble up and down, as needed, when going through list of chosen node to adjust values swap bubble down adjust no bubbling needed (c,2) (b,5) (e,2)
Discussion #35 Chapter 7, Section 5.5 15/15 Dijkstra’s Algorithm vs. Floyd’s Dijkstra’s algorithm is O( m log n ) = O( n 2 log n ) in the worst case. Floyd’s algorithm is O( n 3 ), but computes all shortest paths. Dijkstra’s algorithm can compute all shortest paths by starting it n times, once for each node. Thus, to compute all paths, Dijkstra’s algorithm is O( nm log n ) = O( n 3 log n ) in the worst case. Which is better depends on the application. Dijkstra’s algorithm is better if only a path from a single node to another or to all others is needed. For all paths, Dijkstra’s algorithm is better for sparse graphs, and Floyd’s algorithm is better for dense graphs.
You've reached the end of this preview.
• Winter '12
• MichaelGoodrich
• Graph Theory, Shortest path problem, shortest path, Dijkstra

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern