Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 23 CSE 331 Oct 24, 2011.

Similar presentations


Presentation on theme: "Lecture 23 CSE 331 Oct 24, 2011."— Presentation transcript:

1 Lecture 23 CSE 331 Oct 24, 2011

2 Warning Will not always do COMPLETE proofs More work for YOU

3 Last lecture Convert optimal schedule O to Ô such that Ô has no inversions (a) Exists an inversion (i,j) such that i is scheduled right before j (di > dj) Repeat O(n2) times (a.5) Swap i and j to get O’ (b) O’ has one less inversion than O (c) Max lateness(O’) ≤ Max lateness(O)

4 Max lateness(O’) ≤ Max lateness(O)
di > dj Same lateness Same lateness O i j t1 t3 O’ j i t2 Lateness of j in O’ ≤ Lateness of j in O Lateness of i in O’ ≤ Lateness of j in O Lateness of i in O’ = t3 - di < t3 - dj = Lateness of j in O

5

6 Rest of today Shortest Path Problem

7 Reading Assignment Sec 2.5 of [KT]

8 Shortest Path problem s 100 Input: Directed graph G=(V,E) w
15 5 s u w 100 Input: Directed graph G=(V,E) Edge lengths, le for e in E “start” vertex s in V 15 5 s u w 5 s u Output: All shortest paths from s to all nodes in V

9 Naïve Algorithm Ω(n!) time

10 Dijkstra’s shortest path algorithm
E. W. Dijkstra ( )

11 Dijkstra’s shortest path algorithm
1 d’(w) = min e=(u,w) in E, u in R d(u)+le 1 2 4 3 y 4 3 u d(s) = 0 d(u) = 1 s x 2 4 d(w) = 2 d(x) = 2 d(y) = 3 d(z) = 4 w z 5 4 2 s w Input: Directed G=(V,E), le ≥ 0, s in V u R = {s}, d(s) =0 Shortest paths x While there is a x not in R with (u,x) in E, u in R z y Pick w that minimizes d’(w) Add w to R d(w) = d’(w)

12 Couple of remarks The Dijkstra’s algo does not explicitly compute the shortest paths Can maintain “shortest path tree” separately Dijkstra’s algorithm does not work with negative weights Left as an exercise


Download ppt "Lecture 23 CSE 331 Oct 24, 2011."

Similar presentations


Ads by Google