Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 26 CSE 331 Nov 2, 2012.

Similar presentations


Presentation on theme: "Lecture 26 CSE 331 Nov 2, 2012."— Presentation transcript:

1 Lecture 26 CSE 331 Nov 2, 2012

2 HW 6 due today I will not take any HW after 1:15pm
Q1, Q2 and Q3 in separate piles I will not take any HW after 1:15pm

3 Other HW related stuff Solutions to HW 6 at the end of the lecture
HW 7 has been posted (link on the piazza/blog)

4 Sign up!

5 Dijkstra’s shortest path algorithm
d’(v) = min e=(u,v) in E, u in S d(u)+le Input: Directed G=(V,E), le ≥ 0, s in V S = {s}, d(s) =0 While there is a v not in S with (u,v) in E, u in S At most n iterations Pick w that minimizes d’(w) Add w to S d(w) = d’(w) O(m) time O(mn) time bound is trivial O(m log n) time implementation is possible

6 Reading Assignment Sec 4.4 of [KT]

7 Building a fiber network
Lay down fibers to connect n locations All n locations should be connected Laying down a fiber costs money What is the cheapest way to lay down the fibers?

8 Today’s agenda Minimum Spanning Tree (MST) Problem
Greedy algorithm(s) for MST problem

9 HW 6 due today I will not take any HW after 1:15pm
Q1, Q2 and Q3 in separate piles I will not take any HW after 1:15pm

10 Kruskal’s Algorithm Input: G=(V,E), ce> 0 for every e in E T = Ø
Sort edges in increasing order of their cost Joseph B. Kruskal Consider edges in sorted order If an edge can be added to T without adding a cycle then add it to T

11 Prim’s algorithm Similar to Dijkstra’s algorithm 2 1 3 51 50 0.5
Robert Prim 2 0.5 Input: G=(V,E), ce> 0 for every e in E 1 50 S = {s}, T = Ø While S is not the same as V Among edges e= (u,w) with u in S and w not in S, pick one with minimum cost Add w to S, e to T

12 Reverse-Delete Algorithm
2 1 3 51 50 0.5 Input: G=(V,E), ce> 0 for every e in E 2 0.5 T = E 1 3 50 Sort edges in decreasing order of their cost 51 Consider edges in sorted order If an edge can be removed T without disconnecting T then remove it

13 (Old) History of MST algorithms
1920: Otakar Borůvka 1930: Vojtěch Jarník Same algo! 1956: Kruskal 1957: Prim 1959: Dijkstra


Download ppt "Lecture 26 CSE 331 Nov 2, 2012."

Similar presentations


Ads by Google