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

Size: px
Start display at page:

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

Transcription

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

2 Preliminaries Weighted, directed graphs Weight function: maps edges to real numbers Shortest path weight: δ(u,v) Shortest path estimate: v.d, v V Predecessor: v., v V 320 ShortestPaths 4

3 Negative weight edges & cycles a 3 1 b c d i h g f no negative weight cycles reachable from a means well defined δ(a,v i ) a e b c d 2 i h g f 1 3 δ(a, d) = δ(a, e) = δ(a, f) = negative weight cycles reachable from a means δ(a,v i ) NOT well defined, so δ(a,v i ) where v i = {h, g, i, c} is defined as e 320 ShortestPaths 7

4 Cycles in shortest paths? Short answer: No. Last slide showed no for a negative weight cycle. For a 0 weight cycle, we can remove the cycle and get a path with the same weight. Positive weight cycle: d 5 1 e f ShortestPaths 8

5 Shortest path properties 1 Triangle inequality: (u,v) E, δ(s, v) δ(s, u) + w(u,v) Upper bound: v V, v.d δ(s, v), and once v.d = δ(s, v) it never changes No path: If there is no path from s to v then δ(s, v) = Convergence: If s u v is a shortest path for some u, v V and if u.d = δ(s, u) at any time prior to relaxing (u,v) then u.d = δ(s, u) ever after 320 ShortestPaths 9

6 Shortest path properties 2 Path relaxation: If p = v 0,v 1, v k is a shortest path from s = v 0 to v k, and we relax the edges of p in the order (v 0, v 1 ), (v 1, v 2 ), (v k 1, v k ), then v k.d = δ(s, v k ) Predecessor subgraph: Once v.d = δ(s, v) for all v V, the predecessor subgraph is a shortest paths tree rooted at s 320 ShortestPaths 10

7 Relaxing Check to see if we can improve the shortest path to v found so far by going through u: Yes update v.d and v. No make no changes 320 ShortestPaths 11

8 Questions As we work through the Bellman Ford and Dijkstra algorithms, answer these questions: Why does Bellman Ford work with negative edges? Why doesn t Dijkstra work with negative edges? 320 ShortestPaths 12

9 Procedures INITIALIZE SINGLE SOURCE(G, s) 1 for each vertex v G.V 2 v.d = 3 v. = NIL 4 s.d = 0 RELAX(u, v, w) 1 if v.d > u.d + w(u,v) 2 v.d = u.d + w(u,v) 3 v. = u Complexity? 320 ShortestPaths 13

10 Bellman Ford BELLMAN FORD(G, w, s) 1 INITIALIZE-SINGLE-SOURCE(G, s) 2 for i = 1 to G.V for each edge (u,v) G.E 4 RELAX(u,v,w) 5 for each edge (u,v) G.E 6 if v.d > u.d + w(u,v) 7 return FALSE 8 return TRUE?? 320 ShortestPaths 14

11 Bellman Ford BELLMAN FORD(G, w, s) 1 INITIALIZE-SINGLE-SOURCE(G, s) 2 for i = 1 to G.V for each edge (u,v) G.E 4 RELAX(u,v,w) 5 for each edge (u,v) G.E 6 if v.d > u.d + w(u,v) 7 return FALSE 8 return TRUE Complexity??? 320 ShortestPaths 15

12 INITIALIZE SINGLE SOURCE(G, s) for each vertex v G.V v.d = v. = NIL s.d = 0 RELAX(u, v, w) if v.d > u.d + w(u,v) v.d = u.d + w(u,v) v. = u BELLMAN FORD(G, w, s) INITIALIZE-SINGLE-SOURCE(G, s) for i = 1 to G.V - 1 for each edge (u,v) G.E RELAX(u,v,w) for each edge (u,v) G.E if v.d > u.d + w(u,v) return FALSE return TRUE 320 ShortestPaths 17

13 320 ShortestPaths 18

14 Dijkstra s Algorithm INITIALIZE SINGLE SOURCE(G, s) S = {} MinPQ = G.V while MinPQ u = EXTRACT-MIN(MinPQ) S = S {u} for each v G.Adj[u] RELAX(u,v,w) Complexity? min PQ insert min PQ extract min PQ decrease key If min PQ is an array from 1 to V? Insert, decrease key are O(1), extract min is O(V) 320 ShortestPaths 19

15 Dijkstra s Algorithm INITIALIZE SINGLE SOURCE(G, s) S = {} MinPQ = G.V while MinPQ u = EXTRACT-MIN(MinPQ) S = S {u} for each v G.Adj[u] RELAX(u,v,w) Complexity? min PQ insert min PQ extract min PQ decrease key If min PQ is an array from 1 to V? Insert, decrease key are O(1), extract min is O(V) If min PQ is binary min heap? Build is O(V), extract min, decrease key are O(lg V) 320 ShortestPaths 20

16 Dijkstra s Algorithm INITIALIZE SINGLE SOURCE(G, s) S = {} MinPQ = G.V while MinPQ u = EXTRACT-MIN(MinPQ) S = S {u} for each v G.Adj[u] RELAX(u,v,w) Complexity? min PQ insert min PQ extract min PQ decrease key If min PQ is an array from 1 to V? Insert, decrease key are O(1), extract min is O(V) If min PQ is binary min heap? Build is O(V), extract min, decrease key are O(lg V) If min PQ is a Fibonacci min heap? V extract min ops of O(lg V), E decrease key is O(1) 320 ShortestPaths 21

17 INITIALIZE SINGLE SOURCE(G, s) for each vertex v G.V v.d = v. = NIL s.d = 0 RELAX(u, v, w) if v.d > u.d + w(u,v) v.d = u.d + w(u,v) v. = u DIJKSTRA(G, w, s) INITIALIZE SINGLE SOURCE(G, s) S = {} MinPQ = G.V while MinPQ u = EXTRACT-MIN(MinPQ) S = S {u} for each v G.Adj[u] RELAX(u,v,w) c a b causes re build Dijkstra s 6 d 6 h 3 1 f g e ShortestPaths 22

18 320 ShortestPaths 23

19 Difference Constraints Special case of linear programming Search for a feasible solution to Ax b Value in each node is δ(v 0, v i ) which is a feasible solution for x 320 ShortestPaths 24

20 320 ShortestPaths 25

21 Micro Survey 1 Can you just add to negative weight edges to make them have weights 0 so that Dijkstra s algorithm will work? If we add the absolute value of the largest negative weight (call it x) to each edge to get rid of negative weight, this won t work unless all shortest paths have the same length. As an example, look at a shortest path of 2 edges, then the total path length will be increased by 2x. But if we have another shortest path of 3 edges, then that total path length will be increased by 3x. In addition, if a longer path originally has a smaller weight, you can switch which path has the smaller weight: Consider a graph where there are 2 paths between 2 nodes, a direct edge of length 2, and an indirect route through 2 other nodes with lengths 1, 2, and 2. The second path is shorter. Now say you increase all edge weights by 2, so the direct path is now length 4, and the indirect path is length 6. The direct path is shorter now. 320 AllPairsShortestPaths 27

22 Micro Survey 2 What s the w in Dijkstra s algorithm? It s a function that returns the weight of the edge indicated by its arguments. What s the goal for difference constraints? To find a feasible solution for the x vector, or return false if there is no feasible solution. Recall the equation is: Ax b where A is a matrix and x and b are vectors. With the Bellman Ford algorithm, do we call edges on a negative cycle? No matter how many times we loop will the value ever change? What happens is that we use the edge values we have, and we go through, checking all the edges for V 1 times. Then we check one more time, and we find an instance of v.d > u.d + w(u,v) so we know there s a negative cycle. 320 AllPairsShortestPaths 28

23 Micro Survey 3 Is it true that difference constraints only work for matrices that reduce to each row containing a 1 and a 1? What really happens is that a real problem can directly be stated as a set of difference constraints. What real problems exist for difference constraints? Consider a VLSI layout problem. Constrain it to horizontal layout of a bunch of features and you measure them all from the left edge. You have to have some specified distance between them, maybe so that there s room for routing lines. In that case you can talk about the difference in the horizontal distance of the left edges for each pair of features. This yields difference constraints. And the minimum path will make for a smaller chip. Plus this algorithm tells you if there is no feasible solution to the constraints. 320 AllPairsShortestPaths 29

24 320 ShortestPaths 30

25 Image Credits seattlespt.png: critical path trainset.jpg, trainset.jpg: to calculate critical path float and early and late startsand finishes/ 320 ShortestPaths 32

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Introduction to Algorithms

Introduction to Algorithms 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

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

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

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

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

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

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

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

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

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

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

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo CSE 431/531: Analysis of Algorithms Dynamic Programming Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Paradigms for Designing Algorithms Greedy algorithm Make a

More information

CS 241 Analysis of Algorithms

CS 241 Analysis of Algorithms CS 241 Analysis of Algorithms Professor Eric Aaron Lecture T Th 9:00am Lecture Meeting Location: OLB 205 Business Grading updates: HW5 back today HW7 due Dec. 10 Reading: Ch. 22.1-22.3, Ch. 25.1-2, Ch.

More information

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source

More information

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source Shortest

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

1. (7pts) Find the points of intersection, if any, of the following planes. 3x + 9y + 6z = 3 2x 6y 4z = 2 x + 3y + 2z = 1

1. (7pts) Find the points of intersection, if any, of the following planes. 3x + 9y + 6z = 3 2x 6y 4z = 2 x + 3y + 2z = 1 Math 125 Exam 1 Version 1 February 20, 2006 1. (a) (7pts) Find the points of intersection, if any, of the following planes. Solution: augmented R 1 R 3 3x + 9y + 6z = 3 2x 6y 4z = 2 x + 3y + 2z = 1 3 9

More information

Shortest paths with negative lengths

Shortest paths with negative lengths Chapter 8 Shortest paths with negative lengths In this chapter we give a linear-space, nearly linear-time algorithm that, given a directed planar graph G with real positive and negative lengths, but no

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

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

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

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

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

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

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

Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P

Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P Marc Uetz University of Twente m.uetz@utwente.nl Lecture 8: sheet 1 / 32 Marc Uetz Discrete Optimization Outline 1 Lagrangian

More information

ne a priority queue for the nodes of G; ile (! PQ.is empty( )) select u PQ with d(u) minimal and remove it; I Informatik 1 Kurt Mehlhorn

ne a priority queue for the nodes of G; ile (! PQ.is empty( )) select u PQ with d(u) minimal and remove it; I Informatik 1 Kurt Mehlhorn n-negative Edge Costs: optimal choice: u U with d(u) minimal. e use a priority queue (de nition on next slide) PQ to maintain the set of pairs, d(u)) ; u U } and obtain Dijkstra s Algorithm: ne a priority

More information

7.4 DO (uniqueness of minimum-cost spanning tree) Prove: if all edge weights are distinct then the minimum-cost spanning tree is unique.

7.4 DO (uniqueness of minimum-cost spanning tree) Prove: if all edge weights are distinct then the minimum-cost spanning tree is unique. Algorithms CMSC-700 http://alg1.cs.uchicago.edu Homework set #7. Posted -19. Due Wednesday, February, 01 The following problems were updated on -0: 7.1(a), 7.1(b), 7.9(b) Read the homework instructions

More information

CSE 421 Introduction to Algorithms Final Exam Winter 2005

CSE 421 Introduction to Algorithms Final Exam Winter 2005 NAME: CSE 421 Introduction to Algorithms Final Exam Winter 2005 P. Beame 14 March 2005 DIRECTIONS: Answer the problems on the exam paper. Open book. Open notes. If you need extra space use the back of

More information

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1 NP CS 320, Fall 2017 Dr. Geri Georg, Instructor georg@colostate.edu 320 NP 1 NP Complete A class of problems where: No polynomial time algorithm has been discovered No proof that one doesn t exist 320

More information

Midterm Exam 2 Solutions

Midterm Exam 2 Solutions Algorithm Design and Analysis November 12, 2010 Pennsylvania State University CSE 565, Fall 2010 Professor Adam Smith Exam 2 Solutions Problem 1 (Miscellaneous). Midterm Exam 2 Solutions (a) Your friend

More information

Decision Mathematics D1 Advanced/Advanced Subsidiary. Tuesday 9 June 2015 Morning Time: 1 hour 30 minutes

Decision Mathematics D1 Advanced/Advanced Subsidiary. Tuesday 9 June 2015 Morning Time: 1 hour 30 minutes Paper Reference(s) 6689/01 Edexcel GCE Decision Mathematics D1 Advanced/Advanced Subsidiary Tuesday 9 June 2015 Morning Time: 1 hour 30 minutes Materials required for examination Nil Items included with

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

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

Decision Mathematics D1 Advanced/Advanced Subsidiary. Wednesday 23 January 2013 Morning Time: 1 hour 30 minutes

Decision Mathematics D1 Advanced/Advanced Subsidiary. Wednesday 23 January 2013 Morning Time: 1 hour 30 minutes Paper Reference(s) 6689/01 Edexcel GCE Decision Mathematics D1 Advanced/Advanced Subsidiary Wednesday 23 January 2013 Morning Time: 1 hour 30 minutes Materials required for examination Nil Items included

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

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2006

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2006 University of New Mexico Department of Computer Science Final Examination CS 561 Data Structures and Algorithms Fall, 2006 Name: Email: Print your name and email, neatly in the space provided above; print

More information

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow? CS261, Winter 2017. Instructor: Ashish Goel. Problem set 1 Electronic submission to Gradescope due 11:59pm Thursday 2/2. Form a group of 2-3 students that is, submit one homework with all of your names.

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

Flows. Chapter Circulations

Flows. Chapter Circulations Chapter 4 Flows For a directed graph D = (V,A), we define δ + (U) := {(u,v) A : u U,v / U} as the arcs leaving U and δ (U) := {(u,v) A u / U,v U} as the arcs entering U. 4. Circulations In a directed graph

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

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur Lecture - 20 Travelling Salesman Problem Today we are going to discuss the travelling salesman problem.

More information

9.5. Polynomial and Rational Inequalities. Objectives. Solve quadratic inequalities. Solve polynomial inequalities of degree 3 or greater.

9.5. Polynomial and Rational Inequalities. Objectives. Solve quadratic inequalities. Solve polynomial inequalities of degree 3 or greater. Chapter 9 Section 5 9.5 Polynomial and Rational Inequalities Objectives 1 3 Solve quadratic inequalities. Solve polynomial inequalities of degree 3 or greater. Solve rational inequalities. Objective 1

More information

NP-completeness. Chapter 34. Sergey Bereg

NP-completeness. Chapter 34. Sergey Bereg NP-completeness Chapter 34 Sergey Bereg Oct 2017 Examples Some problems admit polynomial time algorithms, i.e. O(n k ) running time where n is the input size. We will study a class of NP-complete problems

More information

Combinatorial Optimization

Combinatorial Optimization Combinatorial Optimization 2017-2018 1 Maximum matching on bipartite graphs Given a graph G = (V, E), find a maximum cardinal matching. 1.1 Direct algorithms Theorem 1.1 (Petersen, 1891) A matching M is

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

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

Progress on Parallel Chip-Firing

Progress on Parallel Chip-Firing Progress on Parallel Chip-Firing Ziv Scully MIT PRIMES May 2, 2 Ziv Scully (MIT PRIMES) Progress on Parallel Chip-Firing May 2, 2 / 8 Motivation Simple rules Obvious patterns which are difficult to prove,

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

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) The final exam will be on Thursday, May 12, from 8:00 10:00 am, at our regular class location (CSI 2117). It will be closed-book and closed-notes, except

More information

Review Questions, Final Exam

Review Questions, Final Exam Review Questions, Final Exam A few general questions 1. What does the Representation Theorem say (in linear programming)? 2. What is the Fundamental Theorem of Linear Programming? 3. What is the main idea

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

A Simple Implementation Technique for Priority Search Queues

A Simple Implementation Technique for Priority Search Queues A Simple Implementation Technique for Priority Search Queues RALF HINZE Institute of Information and Computing Sciences Utrecht University Email: ralf@cs.uu.nl Homepage: http://www.cs.uu.nl/~ralf/ April,

More information

Fibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17

Fibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17 Fibonacci (Min-)Heap A forest of heap-order trees (parent priority child priority). Roots in circular doubly-linked list. Pointer to minimum-priority root. Siblings in circular doubly-linked list; parent

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

Mathematics for Decision Making: An Introduction. Lecture 13

Mathematics for Decision Making: An Introduction. Lecture 13 Mathematics for Decision Making: An Introduction Lecture 13 Matthias Köppe UC Davis, Mathematics February 17, 2009 13 1 Reminder: Flows in networks General structure: Flows in networks In general, consider

More information

Fiedler s Theorems on Nodal Domains

Fiedler s Theorems on Nodal Domains Spectral Graph Theory Lecture 7 Fiedler s Theorems on Nodal Domains Daniel A. Spielman September 19, 2018 7.1 Overview In today s lecture we will justify some of the behavior we observed when using eigenvectors

More information

Exact Algorithms for Dominating Induced Matching Based on Graph Partition

Exact Algorithms for Dominating Induced Matching Based on Graph Partition Exact Algorithms for Dominating Induced Matching Based on Graph Partition Mingyu Xiao School of Computer Science and Engineering University of Electronic Science and Technology of China Chengdu 611731,

More information

Assignment 5: Solutions

Assignment 5: Solutions Comp 21: Algorithms and Data Structures Assignment : Solutions 1. Heaps. (a) First we remove the minimum key 1 (which we know is located at the root of the heap). We then replace it by the key in the position

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

Review Questions, Final Exam

Review Questions, Final Exam Review Questions, Final Exam A few general questions. What does the Representation Theorem say (in linear programming)? In words, the representation theorem says that any feasible point can be written

More information

A Note on the Connection between the Primal-Dual and the A* Algorithm

A Note on the Connection between the Primal-Dual and the A* Algorithm A Note on the Connection between the Primal-Dual and the A* Algorithm Xugang Ye, Johns Hopkins University, USA Shih-Ping Han, Johns Hopkins University, USA Anhua Lin, Middle Tennessee State University,

More information

Running Time. Assumption. All capacities are integers between 1 and C.

Running Time. Assumption. All capacities are integers between 1 and C. Running Time Assumption. All capacities are integers between and. Invariant. Every flow value f(e) and every residual capacities c f (e) remains an integer throughout the algorithm. Theorem. The algorithm

More information

The Budget-Constrained Maximum Flow Problem

The Budget-Constrained Maximum Flow Problem 9 The Budget-Constrained Maximum Flow Problem In this chapter we consider the following problem which is called the constrained maximum flow problem ( Cmfp) [AO95]: We are given a budget B and we seek

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

CS1800: Strong Induction. Professor Kevin Gold

CS1800: Strong Induction. Professor Kevin Gold CS1800: Strong Induction Professor Kevin Gold Mini-Primer/Refresher on Unrelated Topic: Limits This is meant to be a problem about reasoning about quantifiers, with a little practice of other skills, too

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

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

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010

CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 CSC 5170: Theory of Computational Complexity Lecture 4 The Chinese University of Hong Kong 1 February 2010 Computational complexity studies the amount of resources necessary to perform given computations.

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

A New Approximation Algorithm for the Asymmetric TSP with Triangle Inequality By Markus Bläser

A New Approximation Algorithm for the Asymmetric TSP with Triangle Inequality By Markus Bläser A New Approximation Algorithm for the Asymmetric TSP with Triangle Inequality By Markus Bläser Presented By: Chris Standish chriss@cs.tamu.edu 23 November 2005 1 Outline Problem Definition Frieze s Generic

More information

4 Packing T-joins and T-cuts

4 Packing T-joins and T-cuts 4 Packing T-joins and T-cuts Introduction Graft: A graft consists of a connected graph G = (V, E) with a distinguished subset T V where T is even. T-cut: A T -cut of G is an edge-cut C which separates

More information

CS1800: Mathematical Induction. Professor Kevin Gold

CS1800: Mathematical Induction. Professor Kevin Gold CS1800: Mathematical Induction Professor Kevin Gold Induction: Used to Prove Patterns Just Keep Going For an algorithm, we may want to prove that it just keeps working, no matter how big the input size

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

Decision Mathematics D1 Advanced/Advanced Subsidiary. Tuesday 13 January 2009 Morning Time: 1 hour 30 minutes

Decision Mathematics D1 Advanced/Advanced Subsidiary. Tuesday 13 January 2009 Morning Time: 1 hour 30 minutes Paper Reference(s) 6689/01 Edexcel GCE Decision Mathematics D1 Advanced/Advanced Subsidiary Tuesday 13 January 2009 Morning Time: 1 hour 30 minutes Materials required for examination Nil Items included

More information

cs/ee/ids 143 Communication Networks

cs/ee/ids 143 Communication Networks cs/ee/ids 143 Communication Networks Chapter 5 Routing Text: Walrand & Parakh, 2010 Steven Low CMS, EE, Caltech Warning These notes are not self-contained, probably not understandable, unless you also

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 Reminder: Homework 1 due tonight at 11:59PM! Recap: Greedy Algorithms Interval Scheduling Goal: Maximize number of meeting

More information

Finite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system

Finite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system Finite Math - J-term 07 Lecture Notes - //07 Homework Section 4. - 9, 0, 5, 6, 9, 0,, 4, 6, 0, 50, 5, 54, 55, 56, 6, 65 Section 4. - Systems of Linear Equations in Two Variables Example. Solve the system

More information

CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms

CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms Professor Henry Carter Fall 2016 Recap Space-time tradeoffs allow for faster algorithms at the cost of space complexity overhead Dynamic

More information

Data Mining Prof. Pabitra Mitra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Data Mining Prof. Pabitra Mitra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Data Mining Prof. Pabitra Mitra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 21 K - Nearest Neighbor V In this lecture we discuss; how do we evaluate the

More information

Name: Section Registered In:

Name: Section Registered In: Name: Section Registered In: Math 125 Exam 1 Version 1 February 21, 2006 60 points possible 1. (a) (3pts) Define what it means for a linear system to be inconsistent. Solution: A linear system is inconsistent

More information

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1 CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY E. Amaldi Foundations of Operations Research Politecnico di Milano 1 Goal: Evaluate the computational requirements (this course s focus: time) to solve

More information

Discrete Optimization 2010 Lecture 7 Introduction to Integer Programming

Discrete Optimization 2010 Lecture 7 Introduction to Integer Programming Discrete Optimization 2010 Lecture 7 Introduction to Integer Programming Marc Uetz University of Twente m.uetz@utwente.nl Lecture 8: sheet 1 / 32 Marc Uetz Discrete Optimization Outline 1 Intro: The Matching

More information