lecture 37 - university at buffaloatri/cse331/fall18/lectures/lect37.pdf · lecture 37 cse 331 dec...
TRANSCRIPT
![Page 1: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/1.jpg)
Lecture 37
CSE 331Dec 3, 2018
![Page 2: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/2.jpg)
Quiz 2
1:00-1:10pm
Lecture starts at 1:15pm
![Page 3: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/3.jpg)
Final Reminder
![Page 4: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/4.jpg)
No quiz discussion on piazza
till Noon
![Page 5: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/5.jpg)
Review sessions/extra OHFriday lecture will be a Q&A session
![Page 6: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/6.jpg)
HWs 6-9 solutions
At the end of the lecture
![Page 7: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/7.jpg)
Shortest Path Problem
Input: (Directed) Graph G=(V,E) and for every edge e has a cost ce (can be <0)
t in V
Output: Shortest path from every s to t
1 1
100
-1000
899
s t
Shortest path has cost negative
infinity
Assume that Ghas no negative
cycle
![Page 8: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/8.jpg)
When to use Dynamic Programming
There are polynomially many sub-problems
Optimal solution can be computed from solutions to sub-problems
There is an ordering among sub-problem that allows for iterative solution
Richard Bellman
![Page 9: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/9.jpg)
Sub-problems
OPT(u,i) = cost of shortest path from u to t with at most i edges
![Page 10: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/10.jpg)
Today’s agenda
Finish Bellman-Ford algorithm
Analyze the run time
![Page 11: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/11.jpg)
The recurrence
OPT(u,i) = shortest path from u to t with at most i edges
OPT(u,i) = min { OPT(u,i-1), min(u,w) in E { cu,w + OPT(w, i-1)} }
![Page 12: Lecture 37 - University at Buffaloatri/cse331/fall18/lectures/lect37.pdf · Lecture 37 CSE 331 Dec 3, 2018. Quiz 2 1:00-1:10pm Lecture starts at 1:15pm. Final Reminder. Noquizdiscussiononpiazza](https://reader035.vdocuments.site/reader035/viewer/2022063006/5fb788383a21b23e4c3dd3d4/html5/thumbnails/12.jpg)
Some consequencesOPT(u,i) = cost of shortest path from u to t with at most i edges
OPT(u,i) = min { OPT(u, i-1), min(u,w) in E { cu,w + OPT(w,i-1)} }
OPT(u,n-1) is shortest path cost between u and t
Group talk time:How to compute the shortest path between s and t given all
OPT(u,i) values