lecture_16

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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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 )
Background 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.
Background image of page 3

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

View Full DocumentRight 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 .
Background 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!
Background image of page 5

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

View Full DocumentRight 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 } .
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/10/2008 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

Page1 / 23

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

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online