Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 24 CSE 331 Oct 30, 2009. Homework stuff Please turn in your HW 6 Graded HW 5 and HW 7 at the END of the lecture.

Similar presentations


Presentation on theme: "Lecture 24 CSE 331 Oct 30, 2009. Homework stuff Please turn in your HW 6 Graded HW 5 and HW 7 at the END of the lecture."— Presentation transcript:

1 Lecture 24 CSE 331 Oct 30, 2009

2 Homework stuff Please turn in your HW 6 Graded HW 5 and HW 7 at the END of the lecture

3 Group talk time Form groups of size at most 4 You should always sit with your group Pick a group leader who is responsible for asking group’s questions The groups and group leader can change from lecture to lecture DO THIS NOW!

4 Dijkstra’s shortest path algorithm Input: Directed G=(V,E), l e ≥ 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 d’(v) = min e=(u,v) in E, u in S d(u)+l e Pick w that minimizes d’(w) Add w to S d(w) = d’(w) s s v v u u z z x x y y 1 2 4 3 3 1 2 1 2 d(s) = 0 1 4 2 s s u u d(u) = 1 4 2 v v d(v) = 2 5 x x d(x) = 2 3 4 y y d(y) = 3 z z d(z) = 4 Shortest paths

5 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 Q1 in HW 7

6 Today’s agenda Prove correctness of Dijkstra’s algorithm Efficient implementation of Dijkstra’s algorithm

7 Dijkstra’s shortest path algorithm Input: Directed G=(V,E), l e ≥ 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 d’(v) = min e=(u,v) in E, u in S d(u)+l e Pick w that minimizes d’(w) Add w to S d(w) = d’(w) s s v v u u z z x x y y 1 2 4 3 3 1 2 1 2 d(s) = 0 1 4 2 s s u u d(u) = 1 4 2 v v d(v) = 2 5 x x d(x) = 2 3 4 y y d(y) = 3 z z d(z) = 4 Shortest paths

8 Reading Assignment Sec 4.4 of [KT]


Download ppt "Lecture 24 CSE 331 Oct 30, 2009. Homework stuff Please turn in your HW 6 Graded HW 5 and HW 7 at the END of the lecture."

Similar presentations


Ads by Google