lec15-handout.pdf - Today CMPSCI 311 Introduction to...

This preview shows 1 out of 2 pages.

CMPSCI 311: Introduction to Algorithms Lecture 15: Dynamic Programming 4 Akshay Krishnamurthy University of Massachusetts Last Compiled: March 29, 2018 Today All pairs shortest paths Dynamic programming failure Dynamic programming takeaways Planning and Decision Processes All-pairs shortest paths How fast can we compute all shortest paths in a graph? Djikstra’s gives O ( nm log 2 n ) . (Requires non-negative weights) Bellman-Ford gives O ( n 2 m ) . (Allows negative weights) (new) Floyd-Warshall gives O ( n 3 ) . Problem. Given G = ( V, E, c ) with non-negative weights, compute n × n array M where M [ s, t ] is the cost of shortest s t path. What are good subproblems? Floyd-Warshall algorithm Let cost ( s, t, k ) be cost of shortest s t path using only vertices { 1 , . . . , k } as intermediate points. Consider cost ( s, t, n ) for fixed s, t . If n not on shortest path, then cost ( s, t, n ) = cost ( s, t, n - 1) . Otherwise, cost ( s, t, n ) = cost ( s, n, n - 1) + cost ( n, t, n - 1) . cost ( s, t, k + 1) = min cost ( s, t, k ) cost ( s, k + 1 , k ) + cost ( k + 1 , t, k ) Running time. O ( n 3 ) . Recovering paths requires careful book-keeping.
Image of page 1

Subscribe to view the full document.

Image of page 2
You've reached the end of this preview.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern