130 likes | 143 Views
Understand the Greedy Scheduling Algorithm, proof of structures with zero idle time and inversions, and converting optimal solutions. Also, delve into the Shortest Path Problem using Dijkstra's Algorithm.
E N D
Lecture 22 CSE 331 Oct 15, 2014
Graded Quiz 1 Will hand them out at the END of the lecture
Two definitions for schedules Idle time Max “gap” between two consecutively scheduled tasks Idle time =1 Idle time =0 f=1 Inversion (i,j) is an inversion if i is scheduled before j but di > dj For every i in 1..n do i Schedule job i from si=f to fi=f+ti j f=f+ti j i 0 idle time and 0 inversions for greedy schedule
Proof structure Any two schedules with 0 idle time and 0 inversions have the same max lateness Greedy schedule has 0 idle time and 0 inversions There is an optimal schedule with 0 idle time and 0 inversions
Today’s agenda “Exchange” argument to convert an optimal solution into a 0 inversion one
Rest of Today Shortest Path Problem http://xkcd.com/85/
Reading Assignment Sec 2.5 of [KT]
Shortest Path problem s s s 100 Input: Directed graph G=(V,E) Edge lengths, le for e in E “start” vertex s in V w w 5 5 5 15 15 u u u Output: All shortest paths from s to all nodes in V
Naïve Algorithm Ω(n!) time
Dijkstra’s shortest path algorithm E. W. Dijkstra (1930-2002)
Dijkstra’s shortest path algorithm 1 d’(w) = min e=(u,w) in E, u in Rd(u)+le 3 3 y 4 u 1 1 1 d(s) = 0 d(u) = 1 4 s x 4 2 d(w) = 2 d(x) = 2 2 2 d(y) = 3 d(z) = 4 2 w z 5 4 3 2 s Input: Directed G=(V,E), le ≥ 0, s in V w 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 Pick w that minimizes d’(w) Add w to R z y d(w) = d’(w)
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