Introduction to Algorithms

Size: px
Start display at page:

Download "Introduction to Algorithms"

Transcription

1 Introduction to Algorithms 6.046J/18.401J LECTURE 17 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Erik Demaine November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.1

2 Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v 1 v L v k is defined to be k 1 i= 1 w ( p) = w( v i, v i + 1). November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.

3 Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v 1 v L v k is defined to be Example: k 1 i= 1 w ( p) = w( v i, v i + 1). v 1 v v 3 v 5 v v w(p) = November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.3

4 Shortest paths A shortest path from u to v is a path of minimum weight from u to v. The shortestpath weight from u to v is defined as δ(u, v) = min{w(p) : p is a path from u to v}. Note: δ(u, v) = if no path from u to v exists. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.4

5 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.5

6 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste: November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.6

7 Optimal substructure Theorem. A subpath of a shortest path is a shortest path. Proof. Cut and paste: November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.7

8 Triangle inequality Theorem. For all u, v, x V, we have δ(u, v) δ(u, x) + δ(x, v). November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.8

9 Triangle inequality Theorem. For all u, v, x V, we have δ(u, v) δ(u, x) + δ(x, v). Proof. uu δ(u, v) vv δ(u, x) δ(x, v) xx November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.9

10 Well-definedness of shortest paths If a graph G contains a negative-weight cycle, then some shortest paths may not exist. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.10

11 Well-definedness of shortest paths If a graph G contains a negative-weight cycle, then some shortest paths may not exist. Example: < 0 uu vv November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.11

12 Single-source shortest paths Problem. From a given source vertex s V, find the shortest-path weights δ(s, v) for all v V. If all edge weights w(u, v) are nonnegative, all shortest-path weights must exist. IDEA: Greedy. 1. Maintain a set S of vertices whose shortestpath distances from s are known.. At each step add to S the vertex v V S whose distance estimate from s is minimal. 3. Update the distance estimates of vertices adjacent to v. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.1

13 Dijkstra s algorithm d[s] 0 for each v V {s} do d[v] S Q V Q is a priority queue maintaining V S November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.13

14 Dijkstra s algorithm d[s] 0 for each v V {s} do d[v] S Q V Q is a priority queue maintaining V S while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.14

15 Dijkstra s algorithm d[s] 0 for each v V {s} do d[v] S Q V while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) Q is a priority queue maintaining V S relaxation step Implicit DECREASE-KEY November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.15

16 Example of Dijkstra s algorithm Graph with nonnegative edge weights: AA 10 BB D CC EE November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.16

17 Initialize: Example of Dijkstra s algorithm 0 Q: A B C D E AA 10 3 BB CC D S: {} EE November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.17

18 Example of Dijkstra s algorithm A EXTRACT-MIN(Q): 0 Q: A B C D E AA 10 3 BB CC D S: { A } EE November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.18

19 Example of Dijkstra s algorithm Relax all edges leaving A: 0 Q: A B C D E AA BB D CC S: { A } EE 3 November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.19

20 Example of Dijkstra s algorithm C EXTRACT-MIN(Q): Q: 0 A B C D E AA BB D CC S: { A, C } EE 3 November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.0

21 Example of Dijkstra s algorithm Relax all edges leaving C: Q: 0 A B C D E AA BB D CC S: { A, C } EE 3 5 November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.1

22 Example of Dijkstra s algorithm E EXTRACT-MIN(Q): Q: 0 A B C D E AA BB D CC EE 3 5 S: { A, C, E } November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.

23 Example of Dijkstra s algorithm Relax all edges leaving E: Q: 0 A B C D E AA BB D CC S: { A, C, E } EE 3 5 November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.3

24 Example of Dijkstra s algorithm B EXTRACT-MIN(Q): Q: 0 A B C D E AA BB D CC EE 3 5 S: { A, C, E, B } November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.4

25 Example of Dijkstra s algorithm Relax all edges leaving B: Q: 0 A B C D E AA 7 9 BB D November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L CC S: { A, C, E, B } EE 3 5

26 Example of Dijkstra s algorithm D EXTRACT-MIN(Q): Q: 0 A B C D E AA 7 9 BB D November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L CC EE 3 5 S: { A, C, E, B, D }

27 Correctness Part I Lemma. Initializing d[s] 0 and d[v] for all v V {s} establishes d[v] δ(s, v) for all v V, and this invariant is maintained over any sequence of relaxation steps. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.7

28 Correctness Part I Lemma. Initializing d[s] 0 and d[v] for all v V {s} establishes d[v] δ(s, v) for all v V, and this invariant is maintained over any sequence of relaxation steps. Proof. Suppose not. Let v be the first vertex for which d[v] < δ(s, v), and let u be the vertex that caused d[v] to change: d[v] = d[u] + w(u, v). Then, d[v] < δ(s, v) supposition δ(s, u) + δ(u, v) triangle inequality δ(s,u) + w(u, v) sh. path specific path d[u] + w(u, v) v is first violation Contradiction. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.8

29 Correctness Part II Lemma. Let u be v s predecessor on a shortest path from s to v. Then, if d[u] = δ(s, u) and edge (u, v) is relaxed, we have d[v] = δ(s, v) after the relaxation. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.9

30 Correctness Part II Lemma. Let u be v s predecessor on a shortest path from s to v. Then, if d[u] = δ(s, u) and edge (u, v) is relaxed, we have d[v] = δ(s, v) after the relaxation. Proof. Observe that δ(s, v) = δ(s, u)+ w(u, v). Suppose that d[v] > δ(s, v) before the relaxation. (Otherwise, we re done.) Then, the test d[v] > d[u] + w(u, v) succeeds, because d[v] > δ(s, v) = δ(s, u)+ w(u, v) = d[u] + w(u, v), and the algorithm sets d[v] = d[u] + w(u, v) = δ(s, v). November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.30

31 Correctness Part III Theorem. Dijkstra s algorithm terminates with d[v] = δ(s, v) for all v V. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.31

32 Correctness Part III Theorem. Dijkstra s algorithm terminates with d[v] = δ(s, v) for all v V. Proof. It suffices to show that d[v] = δ(s, v) for every v V when v is added to S. Suppose u is the first vertex added to S for which d[u] >δ(s, u). Let y be the first vertex in V S along a shortest path from s to u, and let x be its predecessor: S, just before adding u. ss xx yy uu November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.3

33 Correctness Part III (continued) ss S xx yy uu Since u is the first vertex violating the claimed invariant, we have d[x] = δ(s, x). When x was added to S, the edge (x, y) was relaxed, which implies that d[y] =δ(s, y) δ(s, u) < d[u]. But, d[u] d[y] by our choice of u. Contradiction. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.33

34 Analysis of Dijkstra while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.34

35 Analysis of Dijkstra V times while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.35

36 Analysis of Dijkstra V times degree(u) times while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.36

37 Analysis of Dijkstra V times degree(u) times while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) Handshaking Lemma Θ(E) implicit DECREASE-KEY s. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.37

38 Analysis of Dijkstra V times degree(u) times while Q do u EXTRACT-MIN(Q) S S {u} for each v Adj[u] do if d[v] > d[u] + w(u, v) then d[v] d[u] + w(u, v) Handshaking Lemma Θ(E) implicit DECREASE-KEY s. Time = Θ(V T EXTRACT -MIN + E T DECREASE-KEY ) Note: Same formula as in the analysis of Prim s minimum spanning tree algorithm. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.38

39 Analysis of Dijkstra (continued) Time = Θ(V) T EXTRACT -MIN + Θ(E) T DECREASE-KEY Q TEXTRACT-MIN T DECREASE -KEY Total November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.39

40 Analysis of Dijkstra (continued) Time = Θ(V) T EXTRACT -MIN + Θ(E) T DECREASE-KEY Q TEXTRACT-MIN T DECREASE -KEY Total array O(V) O(1) O(V ) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.40

41 Analysis of Dijkstra (continued) Time = Θ(V) T EXTRACT -MIN + Θ(E) T DECREASE-KEY Q TEXTRACT-MIN T DECREASE -KEY Total array O(V) O(1) O(V ) binary heap O(lg V) O(lg V) O(E lg V) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.41

42 Analysis of Dijkstra (continued) Time = Θ(V) T EXTRACT -MIN + Θ(E) T DECREASE-KEY Q TEXTRACT-MIN T DECREASE -KEY Total array O(V) O(1) O(V ) binary heap Fibonacci heap O(lg V) O(lg V) O(E lg V) O(lg V) amortized O(1) amortized O(E + V lg V) worst case November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.4

43 Unweighted graphs Suppose that w(u, v) = 1 for all (u, v) E. Can Dijkstra s algorithm be improved? November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.43

44 Unweighted graphs Suppose that w(u, v) = 1 for all (u, v) E. Can Dijkstra s algorithm be improved? Use a simple FIFO queue instead of a priority queue. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.44

45 Unweighted graphs Suppose that w(u, v) = 1 for all (u, v) E. Can Dijkstra s algorithm be improved? Use a simple FIFO queue instead of a priority queue. Breadth-first search while Q do u DEQUEUE(Q) for each v Adj[u] do if d[v] = then d[v] d[u] + 1 ENQUEUE(Q, v) November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.45

46 Unweighted graphs Suppose that w(u, v) = 1 for all (u, v) E. Can Dijkstra s algorithm be improved? Use a simple FIFO queue instead of a priority queue. Breadth-first search while Q do u DEQUEUE(Q) for each v Adj[u] do if d[v] = then d[v] d[u] + 1 ENQUEUE(Q, v) Analysis: Time = O(V + E). November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.46

47 Example of breadth-first search aa bb cc dd ee f gg hh ii Q: November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.47

48 Example of breadth-first search 0 aa bb cc dd ee f gg hh ii 0 Q: a November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.48

49 Example of breadth-first search aa bb cc dd ee 1 1 Q: a b d f gg hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.49

50 Example of breadth-first search aa bb cc dd ee 1 Q: a b d c e f gg hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.50

51 Example of breadth-first search aa bb cc dd ee Q: a bdc e f gg hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.51

52 Example of breadth-first search aa bb cc dd ee Q: a bdce f gg hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.5

53 Example of breadth-first search aa bb cc dd ee 3 f gg Q: a b d c e g i hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.53

54 Example of breadth-first search 0 1 aa bb cc 1 dd ee 3 4 f gg Q: a b d c e g i f hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.54

55 Example of breadth-first search 0 1 aa bb cc 1 dd ee f gg Q: a b d c e g i f h hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.55

56 Example of breadth-first search 0 1 aa bb cc 1 dd ee f gg 3 4 Q: a b d c e g i f h hh ii November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.56

57 Example of breadth-first search 0 1 aa bb cc 1 dd ee f gg 3 hh ii Q: a b d c e g i f h November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.57

58 Example of breadth-first search 0 1 aa bb cc 1 dd ee f gg 3 hh ii Q: a b d c e g i f h November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.58

59 Correctness of BFS while Q do u DEQUEUE(Q) for each v Adj[u] do if d[v] = then d[v] d[u] + 1 ENQUEUE(Q, v) Key idea: The FIFO Q in breadth-first search mimics the priority queue Q in Dijkstra. Invariant: v comes after u in Q implies that d[v] = d[u] or d[v] = d[u] + 1. November 14, 005 Copyright by Erik D. Demaine and Charles E. Leiserson L17.59

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/18.401J LECTURE 14 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Charles E. Leiserson Paths in graphs

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/8.40J/SMA550 Lecture 7 Prof. Erik Demaine Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v v L v k is defined

More information

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya CS6000: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v 1 v L v k

More information

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro.

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro. CMPS 00 Fall 01 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with edge-weight function

More information

Single Source Shortest Paths

Single Source Shortest Paths CMPS 00 Fall 015 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with an edge-weight

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms, Lecture 5 // Introduction to Algorithms 6.46J/.4J LECTURE Shortest Paths I Properties o shortest paths Dijkstra s Correctness Analysis Breadth-irst Pro. Manolis Kellis March,

More information

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk CMPS 6610 Fall 018 Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight function w

More information

Single Source Shortest Paths

Single Source Shortest Paths CMPS 00 Fall 017 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight

More information

CS 4407 Algorithms Lecture: Shortest Path Algorithms

CS 4407 Algorithms Lecture: Shortest Path Algorithms CS 440 Algorithms Lecture: Shortest Path Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Outline Shortest Path Problem General Lemmas and Theorems. Algorithms Bellman-Ford

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 21 Single-Source Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Single-Source

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 18 Prof. Erik Demaine Negative-weight cycles Recall: If a graph G = (V, E) contains a negativeweight cycle, then some shortest paths may not exist.

More information

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees , 2009 Lecture 5: Shortest Paths & Spanning Trees University of Twente m.uetz@utwente.nl wwwhome.math.utwente.nl/~uetzm/dw/ Shortest Path Problem "#$%&'%()*%"()$#+,&- Given directed "#$%&'()*+,%+('-*.#/'01234564'.*,'7+"-%/8',&'5"4'84%#3

More information

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes Analysis of Algorithms Single Source Shortest Path Andres Mendez-Vazquez November 9, 01 1 / 108 Outline 1 Introduction Introduction and Similar Problems General Results Optimal Substructure Properties

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Shortest paths Minimum Spanning Tree Sofya Raskhodnikova 9/14/016 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith,

More information

Shortest Path Algorithms

Shortest Path Algorithms Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Single Source Shortest Path 2 Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node

More information

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths Lecture. Single-Source Shortest Paths All-Pairs Shortest Paths T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to, rd Edition, MIT Press, 009 Sungkyunkwan University Hyunseung Choo choo@skku.edu

More information

Data Structures and and Algorithm Xiaoqing Zheng

Data Structures and and Algorithm Xiaoqing Zheng Data Structures and Algorithm Xiaoqing Zheng zhengxq@fudan.edu.cn Representations of undirected graph 1 2 1 2 5 / 5 4 3 2 3 4 5 1 3 4 / 2 4 / 2 5 3 / 4 1 / Adjacency-list representation of graph G = (V,

More information

CS 253: Algorithms. Chapter 24. Shortest Paths. Credit: Dr. George Bebis

CS 253: Algorithms. Chapter 24. Shortest Paths. Credit: Dr. George Bebis CS : Algorithms Chapter 4 Shortest Paths Credit: Dr. George Bebis Shortest Path Problems How can we find the shortest route between two points on a road map? Model the problem as a graph problem: Road

More information

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker Dijkstra s Single Source Shortest Path Algorithm Andreas Klappenecker Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E -> R. Goal:

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 8 Greedy Algorithms V Huffman Codes Adam Smith Review Questions Let G be a connected undirected graph with distinct edge weights. Answer true or false: Let e be the

More information

BFS Dijkstra. Oct abhi shelat

BFS Dijkstra. Oct abhi shelat 4102 BFS Dijkstra Oct 22 2009 abhi shelat breadth first search bfs(g, a) 1 2 a b 1 2 d c e f g 2 h bfs theorem Theorem 1 (CLRS, p. 599) Let G =(V, E) be a graph and suppose that BFS is run on G from vertex

More information

Lecture Notes for Chapter 25: All-Pairs Shortest Paths

Lecture Notes for Chapter 25: All-Pairs Shortest Paths Lecture Notes for Chapter 25: All-Pairs Shortest Paths Chapter 25 overview Given a directed graph G (V, E), weight function w : E R, V n. Goal: create an n n matrix of shortest-path distances δ(u,v). Could

More information

COMP251: Bipartite graphs

COMP251: Bipartite graphs COMP251: Bipartite graphs Jérôme Waldispühl School of Computer Science McGill University Based on slides fom M. Langer (McGill) & P. Beame (UofW) Recap: Dijkstra s algorithm DIJKSTRA(V, E,w,s) INIT-SINGLE-SOURCE(V,s)

More information

Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao

Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao Homework 3 released Due on 12/13 (Thur) 14:20 (one week only) Mini-HW 9 released Due on 12/13 (Thur) 14:20 Homework 4 released Due on 1/3 (Thur) 14:20 (four

More information

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Breadth First Search, Dijkstra s Algorithm for Shortest Paths CS 374: Algorithms & Models of Computation, Spring 2017 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 17 March 1, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 Part I Breadth

More information

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Matroids Shortest Paths Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Marc Uetz University of Twente m.uetz@utwente.nl Lecture 2: sheet 1 / 25 Marc Uetz Discrete Optimization Matroids

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes

More information

Discrete Optimization 2010 Lecture 3 Maximum Flows

Discrete Optimization 2010 Lecture 3 Maximum Flows Remainder: Shortest Paths Maximum Flows Discrete Optimization 2010 Lecture 3 Maximum Flows Marc Uetz University of Twente m.uetz@utwente.nl Lecture 3: sheet 1 / 29 Marc Uetz Discrete Optimization Outline

More information

COMP251: Bipartite graphs

COMP251: Bipartite graphs COMP251: Bipartite graphs Jérôme Waldispühl School of Computer Science McGill University Based on slides fom M. Langer (McGill) & P. Beame (UofW) Recap: Dijkstra s algorithm DIJKSTRA(V, E,w,s) INIT-SINGLE-SOURCE(V,s)

More information

Myriad of applications

Myriad of applications Shortet Path Myriad of application Finding hortet ditance between location (Google map, etc.) Internet router protocol: OSPF (Open Shortet Path Firt) i ued to find the hortet path to interchange package

More information

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD Greedy s Greedy s Shortest path Claim 2: Let S be a subset of vertices containing s such that we know the shortest path length l(s, u) from s to any vertex in u S. Let e = (u, v) be an edge such that 1

More information

Shortest Paths. CS 320, Fall Dr. Geri Georg, Instructor 320 ShortestPaths 3

Shortest Paths. CS 320, Fall Dr. Geri Georg, Instructor 320 ShortestPaths 3 Shortest Paths CS 320, Fall 2017 Dr. Geri Georg, Instructor georg@colostate.edu 320 ShortestPaths 3 Preliminaries Weighted, directed graphs Weight function: maps edges to real numbers Shortest path weight:

More information

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Contents Lecture 4 Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Jonas Skeppstedt (jonasskeppstedt.net) Lecture 4 2018

More information

Algorithms Booklet. 1 Graph Searching. 1.1 Breadth First Search

Algorithms Booklet. 1 Graph Searching. 1.1 Breadth First Search Algorithms Booklet 2010 Note: in all algorithms, unless stated otherwise, the input graph G is represented by adjacency lists. 1 Graph Searching 1.1 Breadth First Search Algorithm 1: BFS(G, s) Input: G

More information

Algorithms: Lecture 12. Chalmers University of Technology

Algorithms: Lecture 12. Chalmers University of Technology Algorithms: Lecture 1 Chalmers University of Technology Today s Topics Shortest Paths Network Flow Algorithms Shortest Path in a Graph Shortest Path Problem Shortest path network. Directed graph G = (V,

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and

More information

Query Processing in Spatial Network Databases

Query Processing in Spatial Network Databases Temporal and Spatial Data Management Fall 0 Query Processing in Spatial Network Databases SL06 Spatial network databases Shortest Path Incremental Euclidean Restriction Incremental Network Expansion Spatial

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 22 All-Pairs Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 All Pairs

More information

A faster algorithm for the single source shortest path problem with few distinct positive lengths

A faster algorithm for the single source shortest path problem with few distinct positive lengths A faster algorithm for the single source shortest path problem with few distinct positive lengths J. B. Orlin, K. Madduri, K. Subramani, and M. Williamson Journal of Discrete Algorithms 8 (2010) 189 198.

More information

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm 8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements

More information

Breadth-First Search of Graphs

Breadth-First Search of Graphs Breadth-First Search of Graphs Analysis of Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Applications of Breadth-First Search of Graphs a) Single Source

More information

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note

More information

Lecture Notes Discrete Optimization

Lecture Notes Discrete Optimization Lecture Notes Discrete Optimization Bernd Gärtner ETH Zürich (Figures and Proofreading by Hiroyuki Miyazawa) 1 Contents 1 Introduction 4 1.1 The Warehouse Problem From an Ancient Competition..........

More information

ICS 252 Introduction to Computer Design

ICS 252 Introduction to Computer Design ICS 252 fall 2006 Eli Bozorgzadeh Computer Science Department-UCI References and Copyright Textbooks referred [Mic94] G. De Micheli Synthesis and Optimization of Digital Circuits McGraw-Hill, 1994. [CLR90]

More information

Partha Sarathi Mandal

Partha Sarathi Mandal MA 252: Data Structures and Algorithms Lecture 32 http://www.iitg.ernet.in/psm/indexing_ma252/y12/index.html Partha Sarathi Mandal Dept. of Mathematics, IIT Guwahati The All-Pairs Shortest Paths Problem

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 5 Greedy Algorithms Interval Scheduling Interval Partitioning Guest lecturer: Martin Furer Review In a DFS tree of an undirected graph, can there be an edge (u,v)

More information

L feb abhi shelat

L feb abhi shelat L10 661 feb 17 2009 abhi shelat General-MST-Strategy(G =(V, E)) 1 A 2 repeat V 1 times: 3 Pick a cut (S, V S) that respects A 4 Let e be min-weight edge over cut (S, V S) 5 A A {e} prim General-MST-Strategy(G

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 6 Greedy Algorithms Interval Scheduling Interval Partitioning Scheduling to Minimize Lateness Sofya Raskhodnikova S. Raskhodnikova; based on slides by E. Demaine,

More information

Matching Residents to Hospitals

Matching Residents to Hospitals Midterm Review Matching Residents to Hospitals Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair: applicant x and

More information

Discrete Mathematics, Spring 2004 Homework 9 Sample Solutions

Discrete Mathematics, Spring 2004 Homework 9 Sample Solutions Discrete Mathematics, Spring 00 Homework 9 Sample Solutions. #3. A vertex v in a tree T is a center for T if the eccentricity of v is minimal; that is, if the maximum length of a simple path starting from

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Announcement: Homework 1 due soon! Due: January 25 th at midnight (Blackboard) Recap: Graphs Bipartite Graphs Definition

More information

CS781 Lecture 3 January 27, 2011

CS781 Lecture 3 January 27, 2011 CS781 Lecture 3 January 7, 011 Greedy Algorithms Topics: Interval Scheduling and Partitioning Dijkstra s Shortest Path Algorithm Minimum Spanning Trees Single-Link k-clustering Interval Scheduling Interval

More information

1. The graph of a function f is given above. Answer the question: a. Find the value(s) of x where f is not differentiable. Ans: x = 4, x = 3, x = 2,

1. The graph of a function f is given above. Answer the question: a. Find the value(s) of x where f is not differentiable. Ans: x = 4, x = 3, x = 2, 1. The graph of a function f is given above. Answer the question: a. Find the value(s) of x where f is not differentiable. x = 4, x = 3, x = 2, x = 1, x = 1, x = 2, x = 3, x = 4, x = 5 b. Find the value(s)

More information

Scribes: Po-Hsuan Wei, William Kuzmaul Editor: Kevin Wu Date: October 18, 2016

Scribes: Po-Hsuan Wei, William Kuzmaul Editor: Kevin Wu Date: October 18, 2016 CS 267 Lecture 7 Graph Spanners Scribes: Po-Hsuan Wei, William Kuzmaul Editor: Kevin Wu Date: October 18, 2016 1 Graph Spanners Our goal is to compress information about distances in a graph by looking

More information

Worksheets for GCSE Mathematics. Quadratics. mr-mathematics.com Maths Resources for Teachers. Algebra

Worksheets for GCSE Mathematics. Quadratics. mr-mathematics.com Maths Resources for Teachers. Algebra Worksheets for GCSE Mathematics Quadratics mr-mathematics.com Maths Resources for Teachers Algebra Quadratics Worksheets Contents Differentiated Independent Learning Worksheets Solving x + bx + c by factorisation

More information

Ngày 20 tháng 7 năm Discrete Optimization Graphs

Ngày 20 tháng 7 năm Discrete Optimization Graphs Discrete Optimization Graphs Ngày 20 tháng 7 năm 2011 Lecture 6: Graphs In this class we shall prove some simple, useful theorems about graphs. We start with very simple obseravations. Lecture 6: Graphs

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Fall 205 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 7 October 22, 205 Chandra & Manoj (UIUC) CS374 Fall 205 / 54 Part I Shortest Paths with

More information

16.1 Min-Cut as an LP

16.1 Min-Cut as an LP 600.469 / 600.669 Approximation Algorithms Lecturer: Michael Dinitz Topic: LPs as Metrics: Min Cut and Multiway Cut Date: 4//5 Scribe: Gabriel Kaptchuk 6. Min-Cut as an LP We recall the basic definition

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Spring 207 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 8 March 28, 207 Chandra Chekuri (UIUC) CS374 Spring 207 / 56 Part I Shortest Paths

More information

IS 709/809: Computational Methods in IS Research Fall Exam Review

IS 709/809: Computational Methods in IS Research Fall Exam Review IS 709/809: Computational Methods in IS Research Fall 2017 Exam Review Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Exam When: Tuesday (11/28) 7:10pm

More information

Solutions to Exercises

Solutions to Exercises 1/13 Solutions to Exercises The exercises referred to as WS 1.1(a), and so forth, are from the course book: Williamson and Shmoys, The Design of Approximation Algorithms, Cambridge University Press, 2011,

More information

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4 CS 0/58,, Biconnectivity Let G = (N,E) be a connected A node a N is an articulation point if there are v and w different from a such that every path from 0 9 8 3 5 7 6 David Maier Biconnected Component

More information

CSE 591 Foundations of Algorithms Homework 4 Sample Solution Outlines. Problem 1

CSE 591 Foundations of Algorithms Homework 4 Sample Solution Outlines. Problem 1 CSE 591 Foundations of Algorithms Homework 4 Sample Solution Outlines Problem 1 (a) Consider the situation in the figure, every edge has the same weight and V = n = 2k + 2. Easy to check, every simple

More information

Another way of saying this is that amortized analysis guarantees the average case performance of each operation in the worst case.

Another way of saying this is that amortized analysis guarantees the average case performance of each operation in the worst case. Amortized Analysis: CLRS Chapter 17 Last revised: August 30, 2006 1 In amortized analysis we try to analyze the time required by a sequence of operations. There are many situations in which, even though

More information

Analysis of Algorithms I: All-Pairs Shortest Paths

Analysis of Algorithms I: All-Pairs Shortest Paths Analysis of Algorithms I: All-Pairs Shortest Paths Xi Chen Columbia University The All-Pairs Shortest Paths Problem. Input: A directed weighted graph G = (V, E) with an edge-weight function w : E R. Output:

More information

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11 Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. V = {, 2, 3,,,, 7, 8 } E

More information

CS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS

CS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS UNIT V GRAPHS Representation of Graphs Breadth-first search Depth-first search Topological sort Minimum Spanning Trees Kruskal and Prim algorithm Shortest path algorithm Dijkstra s algorithm Bellman-Ford

More information

Examination paper for TDT4120 Algorithms and Data Structures

Examination paper for TDT4120 Algorithms and Data Structures Examination paper for TDT4120 Algorithms and Data Structures Academic contact during examination Magnus Lie Hetland Phone 91851949 Examination date December 7, 2013 Examination time (from to) 0900 1300

More information

The Matching Polytope: General graphs

The Matching Polytope: General graphs 8.433 Combinatorial Optimization The Matching Polytope: General graphs September 8 Lecturer: Santosh Vempala A matching M corresponds to a vector x M = (0, 0,,, 0...0) where x M e is iff e M and 0 if e

More information

INVERSE SPANNING TREE PROBLEMS: FORMULATIONS AND ALGORITHMS

INVERSE SPANNING TREE PROBLEMS: FORMULATIONS AND ALGORITHMS INVERSE SPANNING TREE PROBLEMS: FORMULATIONS AND ALGORITHMS P. T. Sokkalingam Department of Mathematics Indian Institute of Technology, Kanpur-208 016, INDIA Ravindra K. Ahuja Dept. of Industrial & Management

More information

All-Pairs Shortest Paths

All-Pairs Shortest Paths All-Pairs Shortest Paths Version of October 28, 2016 Version of October 28, 2016 All-Pairs Shortest Paths 1 / 26 Outline Another example of dynamic programming Will see two different dynamic programming

More information

Algorithms and Data Structures (COMP 251) Midterm Solutions

Algorithms and Data Structures (COMP 251) Midterm Solutions Algorithms and Data Structures COMP 251) Midterm Solutions March 11, 2012 1. Stable Matching Problem a) Describe the input for the stable matching problem. Input: n men and n women. For each man, there

More information

Part IA Algorithms Notes

Part IA Algorithms Notes Part IA Algorithms Notes 1 Sorting 1.1 Insertion Sort 1 d e f i n s e r t i o n S o r t ( a ) : 2 f o r i from 1 i n c l u d e d to l e n ( a ) excluded : 3 4 j = i 1 5 w h i l e j >= 0 and a [ i ] > a

More information

arxiv: v1 [cs.cg] 29 Jun 2012

arxiv: v1 [cs.cg] 29 Jun 2012 Single-Source Dilation-Bounded Minimum Spanning Trees Otfried Cheong Changryeol Lee May 2, 2014 arxiv:1206.6943v1 [cs.cg] 29 Jun 2012 Abstract Given a set S of points in the plane, a geometric network

More information

arxiv: v1 [cs.ds] 20 Nov 2016

arxiv: v1 [cs.ds] 20 Nov 2016 Algorithmic and Hardness Results for the Hub Labeling Problem Haris Angelidakis 1, Yury Makarychev 1 and Vsevolod Oparin 2 1 Toyota Technological Institute at Chicago 2 Saint Petersburg Academic University

More information

Discrete Mathematics

Discrete Mathematics Discrete Mathematics 309 (009) 3811 380 Contents lists available at ScienceDirect Discrete Mathematics journal homepage: www.elsevier.com/locate/disc Disjoint hamiltonian cycles in bipartite graphs Michael

More information

Terms of Use. Copyright Embark on the Journey

Terms of Use. Copyright Embark on the Journey Terms of Use All rights reserved. No part of this packet may be reproduced, stored in a retrieval system, or transmitted in any form by any means - electronic, mechanical, photo-copies, recording, or otherwise

More information

Question Paper Code :

Question Paper Code : www.vidyarthiplus.com Reg. No. : B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2011. Time : Three hours Fourth Semester Computer Science and Engineering CS 2251 DESIGN AND ANALYSIS OF ALGORITHMS (Regulation

More information

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov Dynamic Programming Data Structures and Algorithms Andrei Bulatov Algorithms Dynamic Programming 18-2 Weighted Interval Scheduling Weighted interval scheduling problem. Instance A set of n jobs. Job j

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees 695 25. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci Heaps [Ottman/Widmayer, Kap. 9.6, 6.2, 6.1, Cormen et al,

More information

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn

Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Priority Queue / Heap Stores (key,data) pairs (like dictionary) But, different set of operations: Initialize-Heap: creates new empty heap

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees Problem Given: Undirected, weighted, connected graph G = (V, E, c). 5. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci

More information

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected. 4 Connectivity 2-connectivity Separation: A separation of G of order k is a pair of subgraphs (H, K) with H K = G and E(H K) = and V (H) V (K) = k. Such a separation is proper if V (H) \ V (K) and V (K)

More information

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected. 4 Connectivity 2-connectivity Separation: A separation of G of order k is a pair of subgraphs (H 1, H 2 ) so that H 1 H 2 = G E(H 1 ) E(H 2 ) = V (H 1 ) V (H 2 ) = k Such a separation is proper if V (H

More information

CMPSCI 611: Advanced Algorithms

CMPSCI 611: Advanced Algorithms CMPSCI 611: Advanced Algorithms Lecture 12: Network Flow Part II Andrew McGregor Last Compiled: December 14, 2017 1/26 Definitions Input: Directed Graph G = (V, E) Capacities C(u, v) > 0 for (u, v) E and

More information

Connectivity of addable graph classes

Connectivity of addable graph classes Connectivity of addable graph classes Paul Balister Béla Bollobás Stefanie Gerke July 6, 008 A non-empty class A of labelled graphs is weakly addable if for each graph G A and any two distinct components

More information

Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths. Reading: AM&O Chapter 5

Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths. Reading: AM&O Chapter 5 Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths Reading: AM&O Chapter Label Correcting Methods Assume the network G is allowed to have negative arc lengths but no directed negativelyweighted

More information

from notes written mostly by Dr. Matt Stallmann: All Rights Reserved

from notes written mostly by Dr. Matt Stallmann: All Rights Reserved CSC 505, Fall 000: Week 0 Objectives: understand problem complexity and classes defined by it understand relationships among decision, witness, evaluation, and optimization problems understand what it

More information

Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.

Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Princeton University COS 4 Theory of Algorithms Spring 2002 Kevin Wayne Priority Queues Operation mae-heap insert find- delete- union

More information

Introduction to Algorithms

Introduction to Algorithms Introducton to Algorthms 6.046J/8.40J LECTURE 6 Shortest Paths III All-pars shortest paths Matrx-multplcaton algorthm Floyd-Warshall algorthm Johnson s algorthm Prof. Charles E. Leserson Shortest paths

More information

Greedy Alg: Huffman abhi shelat

Greedy Alg: Huffman abhi shelat L15 Greedy Alg: Huffman 4102 10.17.201 abhi shelat Huffman Coding image: wikimedia In testimony before the committee, Mr. Lew stressed that the Treasury Department would run out of extraordinary measures

More information

Impossibility of Distributed Consensus with One Faulty Process

Impossibility of Distributed Consensus with One Faulty Process Impossibility of Distributed Consensus with One Faulty Process Journal of the ACM 32(2):374-382, April 1985. MJ Fischer, NA Lynch, MS Peterson. Won the 2002 Dijkstra Award (for influential paper in distributed

More information

MA015: Graph Algorithms

MA015: Graph Algorithms MA015 3. Minimum cuts 1 MA015: Graph Algorithms 3. Minimum cuts (in undirected graphs) Jan Obdržálek obdrzalek@fi.muni.cz Faculty of Informatics, Masaryk University, Brno All pairs flows/cuts MA015 3.

More information

Chapter 6. Properties of Regular Languages

Chapter 6. Properties of Regular Languages Chapter 6 Properties of Regular Languages Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is

More information

22 Max-Flow Algorithms

22 Max-Flow Algorithms A process cannot be understood by stopping it. Understanding must move with the flow of the process, must join it and flow with it. The First Law of Mentat, in Frank Herbert s Dune (965) There s a difference

More information

6.889 Lecture 4: Single-Source Shortest Paths

6.889 Lecture 4: Single-Source Shortest Paths 6.889 Lecture 4: Single-Source Shortest Paths Christian Sommer csom@mit.edu September 19 and 26, 2011 Single-Source Shortest Path SSSP) Problem: given a graph G = V, E) and a source vertex s V, compute

More information

Uncertain Compression & Graph Coloring. Madhu Sudan Harvard

Uncertain Compression & Graph Coloring. Madhu Sudan Harvard Uncertain Compression & Graph Coloring Madhu Sudan Harvard Based on joint works with: (1) Adam Kalai (MSR), Sanjeev Khanna (U.Penn), Brendan Juba (WUStL) (2) Elad Haramaty (Harvard) (3) Badih Ghazi (MIT),

More information

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016 University of Toronto Department of Electrical and Computer Engineering Final Examination ECE 345 Algorithms and Data Structures Fall 2016 Print your first name, last name, UTORid, and student number neatly

More information

CMPUT 675: Approximation Algorithms Fall 2014

CMPUT 675: Approximation Algorithms Fall 2014 CMPUT 675: Approximation Algorithms Fall 204 Lecture 25 (Nov 3 & 5): Group Steiner Tree Lecturer: Zachary Friggstad Scribe: Zachary Friggstad 25. Group Steiner Tree In this problem, we are given a graph

More information

CMU Lecture 4: Informed Search. Teacher: Gianni A. Di Caro

CMU Lecture 4: Informed Search. Teacher: Gianni A. Di Caro CMU 15-781 Lecture 4: Informed Search Teacher: Gianni A. Di Caro UNINFORMED VS. INFORMED Uninformed Can only generate successors and distinguish goals from non-goals Informed Strategies that can distinguish

More information