35-DijkstrasAlg

35-DijkstrasAlg - Discussion #35 Dijkstra's Algorithm...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Discussion #35 Chapter 7, Section 5.5 1/15 Discussion #35 Dijkstra’s Algorithm
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Discussion #35 Chapter 7, Section 5.5 2/15 Topics Shortest path Greedy algorithms Dijkstra’s algorithm
Background image of page 2
Discussion #35 Chapter 7, Section 5.5 3/15 Shortest Path Minimum length path from one node to another (e.g. from a to e , the shortest path is 2) Algorithms Breadth-First-Search, O( n 2 ) in the worst case Floyd’s, O( n 3 ); but finds all BFS, starting at each node, O( nm ), which beats Floyd’s for sparse graphs b c a e d
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Discussion #35 Chapter 7, Section 5.5 4/15 Shortest Path in Weighted Graphs Weights on edges: positive numbers Algorithms Simple BFS no longer works (e.g. the shortest path from a to b is not the edge that connects them) Floyd’s, O( n 3 ); finds all Is there an algorithm that beats Floyd’s? for the single best path? for all paths? b c a e d 5 2 2 1 10 1 1
Background image of page 4
Discussion #35 Chapter 7, Section 5.5 5/15 Dijkstra’s Algorithm Find the shortest weighted path between two given nodes. (Easier to find the minimum from one to all.) Intuitively, special BFS: choose smallest accumulated path length Algorithm b c a e d 5 2 2 1 10 1 1 1. Initialize D (distance) table. 2. Until all nodes are settled, 2a. find smallest distance & settle node. 2b. adjust distances in D for unsettled nodes.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Discussion #35 Chapter 7, Section 5.5 6/15 Important Aside: Greedy Algorithms A greedy algorithm always takes the best immediate or local solution while finding an answer. Greedy algorithms find optimal solutions for some optimization problems, but may find (far) less- than-optimal solutions for other optimization problems.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/02/2012 for the course C S 236 taught by Professor Michaelgoodrich during the Winter '12 term at BYU.

Page1 / 15

35-DijkstrasAlg - Discussion #35 Dijkstra's Algorithm...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online