{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_16 - Introduction to Algorithms 6.046J/18.401J...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 16 Shortest Paths III All-pairs shortest paths Matrix-multiplication algorithm Floyd-Warshall algorithm Johnson’s algorithm
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Introduction to Algorithms November 8, 2004 L16.2 © 2001–4 by Charles E. Leiserson Shortest paths Single-source shortest paths Nonnegative edge weights Dijkstra’s algorithm: O ( E + V lg V ) General Bellman-Ford algorithm: O ( VE ) DAG One pass of Bellman-Ford: O ( V + E )
Image of page 2
Introduction to Algorithms November 8, 2004 L16.3 © 2001–4 by Charles E. Leiserson Shortest paths Single-source shortest paths Nonnegative edge weights Dijkstra’s algorithm: O ( E + V lg V ) General Bellman-Ford: O ( VE ) DAG One pass of Bellman-Ford: O ( V + E ) All-pairs shortest paths Nonnegative edge weights Dijkstra’s algorithm | V | times: O ( VE + V 2 lg V ) General Three algorithms today.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Introduction to Algorithms November 8, 2004 L16.4 © 2001–4 by Charles E. Leiserson All-pairs shortest paths Input: Digraph G = ( V , E ) , where V = {1, 2, …, n } , with edge-weight function w : E R . Output: n × n matrix of shortest-path lengths δ ( i , j ) for all i , j V .
Image of page 4
Introduction to Algorithms November 8, 2004 L16.5 © 2001–4 by Charles E. Leiserson All-pairs shortest paths Input: Digraph G = ( V , E ) , where V = {1, 2, …, n } , with edge-weight function w : E R . Output: n × n matrix of shortest-path lengths δ ( i , j ) for all i , j V . I DEA : Run Bellman-Ford once from each vertex. Time = O( V 2 E ) . Dense graph ( n 2 edges) ⇒ Θ ( n 4 ) time in the worst case. Good first try!
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Introduction to Algorithms November 8, 2004 L16.6 © 2001–4 by Charles E. Leiserson Dynamic programming Consider the n × n adjacency matrix A = ( a ij ) of the digraph, and define d ij (0) = 0 if i = j , if i j ; Claim: We have and for m = 1, 2, …, n – 1 , d ij ( m ) = min k { d ik ( m– 1) + a kj } .
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ 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