{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

35-DijkstrasAlg

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

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

Discussion #35 Chapter 7, Section 5.5 1/15 Discussion #35 Dijkstra’s Algorithm

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

View Full Document
Discussion #35 Chapter 7, Section 5.5 2/15 Topics Shortest path Greedy algorithms Dijkstra’s algorithm
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

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

View Full Document
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
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.

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

View Full Document
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.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}