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

Size: px
Start display at page:

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

Transcription

1 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 David Maier Biconnected Component Maximal subgraph that is still connected after Express in terms of edges Articulation point must lie in two components David Maier

2 CS 0/58,, DFS and Articulation Points Tree, back edges in DFS give clue to articulation points If a is an articulation point that splits v and w, then David Maier 3 DFS and Articulation Points Lemma: G = (N,E) is S = (N,T) is Node a is an articulation i point if and only if. a is the root of S and or. a is not the root and a has some child c in S where there is no David Maier

3 CS 0/58,, Low Numbers For graph G = (N,E), let T = B = For simplicity, assume DFNum[v] = How high (lowest DFNum) can we hop from a node on a back edge? LOW[v] = min({v} {w there is {x,w} in B where David Maier 5 Calculating Low If {x,w} in B and w < v then Also, v is an articulation point if for some child c of v, LOW[c] Calculate LOW during DFS LOW[v] is minimum of.. 3. David Maier 6 3

4 CS 0/58,, Biconnected Components Algorithm Count Parent[v] BI(v) mark v DFNum[v] Count, increment Count Low[v] DFNum[v] David Maier 7 Algorithm Cont. for each edge {v,w} do if w not marked then if LOW[w] DFNum[v] and v not root then LOW[v] else if PARENT[v] w then LOW[v] Need a check at end if root is an articulation point. David Maier 8

5 CS 0/58,, Example David Maier 9 Minimum Cost Spanning Tree G = (N, E) Cost function c gives edge weights A spanning tree is a graph S = ( ) where E E and S is a David Maier 0 5

6 CS 0/58,, Cost of a spanning tree S = (N,E ) is e E Cost of a Spanning Tree Want minimum cost Lemma: Let S = (N,E ) be a spanning tree for G = (N,E). Then a. for v, v in N b. adding an edge from E-E to S David Maier Spanning Forest A set of trees {(N,E ), (N,E ),..., (N k,e k )} Where N = E i E E j David Maier 6

7 CS 0/58,, Expanding a Spanning Forest Lemma: Suppose we have a spanning forest of k > trees. Let E = Let e = {v,w} be such that v N, w N. Then there is a spanning tree for G that includes E and has minimal cost among trees that include E. What kind of algorithm is this leading us towards? David Maier 3 Proof of Lemma Suppose not. Let S = (N,E ), E E, have lower cost than any spanning tree Adding e to S causes v w N v w David Maier 7

8 CS 0/58,, Proof of Lemma S must have an edge e = {v,w } with We know c(e) Let S = S S has no cycles c(e ) S is still a tree David Maier 5 Greedy Strategy Take least cost edge e in E. By last lemma, [Consider an initial spanning forest {({ }, ), ({ }, ),..., ({ }, )} ] David Maier 6 8

9 CS 0/58,, Iterative Step Let {(N,E ),(N,E ),...,(N k,e k )} be a spanning forest that is Add the lowest cost edge that By the last lemma, the result is David Maier 7 Kruskal s Algorithm KRUSKAL(G(N,E)) S NS {{v },{v },...,{v n }} Q while NS > do {v,w} if Find(v) Find(w) then S S Union( ) David Maier 8 9

10 CS 0/58,, Example Q c NS {,5} {} {} {3} {} {5} {6} {3,} {,} 3 {,5} 3 {,3} {,6} {,3} 6 {5,6} 7 David Maier 9 Complexity Priority Queue: sort, make a list Union/Find # Union s = # Find s = Can do a little better keep a heap of edges by cost David Maier 0 0

11 CS 0/58,, Path Problems Directed graphs with labels on edges a b 3 c e d 5 f David Maier Shortest Path Labels could be non-negative integers Use for David Maier

12 CS 0/58,, Connectivity Labels could be Boolean values Use for David Maier 3 Finite Automata Labels could be symbols from an alphabet (as in a finite automaton). Use for a b 3 b a b 5 a David Maier

13 CS 0/58,, Path Algorithms Can produce generic algorithms, just need definitions for Can take advantage of identities Two kinds of algorithms.. Can do. with David Maier 5 Dijkstra s Algorithm Single-source, shortest path in a digraph v 0 v v 5 v 3 v v 6 v 7 v 8 v5 S D array of distances David Maier 6 3

14 CS 0/58,, General Step Add node not in S with minimum D value to S. Update distances to nodes in N-S Is S still correct? S v 0 w suppose not shortest David Maier 7 Full Algorithm G = (N,E) lab(v,w) - label represent with matrix S {v 0 } D[v 0 ] 0 D[v] lab(v 0,v) for rest while S N do choose w S for all v in N-S do D[v] David Maier 8

15 CS 0/58,, Example S D[] D[] D[3] D[] D[5] {} 0 David Maier 9 Warshall s Algorithm Transitive Closure 3 5 Basic op k v w Consider each k only once v k w David Maier 30 5

16 CS 0/58,, Algorithm for k = to n do for v = to n do if a[v,k] then for w = to n do if a[k,w] then David Maier 3 Example David Maier 3 6

17 CS 0/58,, Floyd s Algorithm All-pairs shortest path v k w for k = to n do for v = to n do if d[v,k] then for w = to n do d[v,w] David Maier 33 Example d[i,j] David Maier 3 7

18 CS 0/58,, Example 3 d[i,j] d[i,j] 3 David Maier 35 Example 3 3 d[i,j] d[i,j] David Maier 36 8

19 CS 0/58,, Example 3 3 d[i,j] d[i,j] 3 3 David Maier 37 9

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

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

CS 410/584, Algorithm Design & Analysis: Lecture Notes 3

CS 410/584, Algorithm Design & Analysis: Lecture Notes 3 CS 410/584, : Lecture Notes 3 Amortized Cost Not an algorithm design mechanism per se For analyzing cost of algorithms - - Example: Exercise 17.3-6 Implement a queue with two stacks Why? 1 enqueue(x, Q)

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

1. (12 points) Give a table-driven parse table for the following grammar: 1) X ax 2) X P 3) P DT 4) T P 5) T ε 7) D 1

1. (12 points) Give a table-driven parse table for the following grammar: 1) X ax 2) X P 3) P DT 4) T P 5) T ε 7) D 1 1. (12 points) Give a table-driven parse table for the following grammar: 1) X ax 2) X P 3) P DT 4) T P 5) T ε 6) D 0 7) D 1 4. Recall that our class database has the following schemas: SNAP(StudentID,

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

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

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

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)} Preliminaries Graphs G = (V, E), V : set of vertices E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) 1 2 3 5 4 V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)} 1 Directed Graph (Digraph)

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

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

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

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

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

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

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

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

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

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

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

Ring Sums, Bridges and Fundamental Sets

Ring Sums, Bridges and Fundamental Sets 1 Ring Sums Definition 1 Given two graphs G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 ) we define the ring sum G 1 G 2 = (V 1 V 2, (E 1 E 2 ) (E 1 E 2 )) with isolated points dropped. So an edge is in G 1 G

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

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

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

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

CSE 332. Data Abstractions

CSE 332. Data Abstractions Adam Blank Lecture 23 Autumn 2015 CSE 332 Data Abstractions CSE 332: Data Abstractions Graphs 4: Minimum Spanning Trees Final Dijkstra s Algorithm 1 1 dijkstra(g, source) { 2 dist = new Dictionary(); 3

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

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

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

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

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

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

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

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions Copyright c 2015 Andrew Klapper. All rights reserved. 1. For the functions satisfying the following three recurrences, determine which is the

More information

Formal Languages, Automata and Compilers

Formal Languages, Automata and Compilers Formal Languages, Automata and Compilers Lecure 4 2017-18 LFAC (2017-18) Lecture 4 1 / 31 Curs 4 1 Grammars of type 3 and finite automata 2 Closure properties for type 3 languages 3 Regular Expressions

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

Greedy. Outline CS141. Stefano Lonardi, UCR 1. Activity selection Fractional knapsack Huffman encoding Later:

Greedy. Outline CS141. Stefano Lonardi, UCR 1. Activity selection Fractional knapsack Huffman encoding Later: October 5, 017 Greedy Chapters 5 of Dasgupta et al. 1 Activity selection Fractional knapsack Huffman encoding Later: Outline Dijkstra (single source shortest path) Prim and Kruskal (minimum spanning tree)

More information

Solutions. Prelim 2[Solutions]

Solutions. Prelim 2[Solutions] Prelim [Solutions]. Short Answer [ pts] (a) [ pts] A traversal of an expression tree produces the string + + 3. i. What kind of traversal is it? Preorder; the operator is printed before the operands. ii.

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 20: Algorithm Design Techniques 12/2/2015 Daniel Bauer 1 Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways of

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

5. Biconnected Components of A Graph

5. Biconnected Components of A Graph 5. Biconnected Components of A Graph If one city s airport is closed by bad eather, can you still fly beteen any other pair of cities? If one computer in a netork goes don, can a message be sent beteen

More information

CS 161: Design and Analysis of Algorithms

CS 161: Design and Analysis of Algorithms CS 161: Design and Analysis of Algorithms Greedy Algorithms 3: Minimum Spanning Trees/Scheduling Disjoint Sets, continued Analysis of Kruskal s Algorithm Interval Scheduling Disjoint Sets, Continued Each

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

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

CSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions

CSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions CSE 502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions 1. Consider the following algorithm: for i := 1 to α n log e n do Pick a random j [1, n]; If a[j] = a[j + 1] or a[j] = a[j 1] then output:

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

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

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

Path Queries under Distortions: Answering and Containment

Path Queries under Distortions: Answering and Containment Path Queries under Distortions: Answering and Containment Gosta Grahne Concordia University Alex Thomo Suffolk University Foundations of Information and Knowledge Systems (FoIKS 04) Postulate 1 The world

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

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

Slides for CIS 675. Huffman Encoding, 1. Huffman Encoding, 2. Huffman Encoding, 3. Encoding 1. DPV Chapter 5, Part 2. Encoding 2

Slides for CIS 675. Huffman Encoding, 1. Huffman Encoding, 2. Huffman Encoding, 3. Encoding 1. DPV Chapter 5, Part 2. Encoding 2 Huffman Encoding, 1 EECS Slides for CIS 675 DPV Chapter 5, Part 2 Jim Royer October 13, 2009 A toy example: Suppose our alphabet is { A, B, C, D }. Suppose T is a text of 130 million characters. What is

More information

CMPSCI611: The Matroid Theorem Lecture 5

CMPSCI611: The Matroid Theorem Lecture 5 CMPSCI611: The Matroid Theorem Lecture 5 We first review our definitions: A subset system is a set E together with a set of subsets of E, called I, such that I is closed under inclusion. This means that

More information

CS213d Data Structures and Algorithms

CS213d Data Structures and Algorithms CS21d Data Structures and Algorithms Heaps and their Applications Milind Sohoni IIT Bombay and IIT Dharwad March 22, 2017 1 / 18 What did I see today? March 22, 2017 2 / 18 Heap-Trees A tree T of height

More information

Prelim 2[Solutions] Solutions. 1. Short Answer [18 pts]

Prelim 2[Solutions] Solutions. 1. Short Answer [18 pts] Prelim [Solutions]. Short Answer [8 pts] (a) [3 pts] In a model/view/controller, Swing is likely to be part of (there may be more than one): i. the model ii. the view iii. the controller The view and the

More information

Algorithm Design Strategies V

Algorithm Design Strategies V Algorithm Design Strategies V Joaquim Madeira Version 0.0 October 2016 U. Aveiro, October 2016 1 Overview The 0-1 Knapsack Problem Revisited The Fractional Knapsack Problem Greedy Algorithms Example Coin

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

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

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic).

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic). Trees A tree is a graph which is (a) Connected and (b) has no cycles (acyclic). 1 Lemma 1 Let the components of G be C 1, C 2,..., C r, Suppose e = (u, v) / E, u C i, v C j. (a) i = j ω(g + e) = ω(g).

More information

(tree searching technique) (Boolean formulas) satisfying assignment: (X 1, X 2 )

(tree searching technique) (Boolean formulas) satisfying assignment: (X 1, X 2 ) Algorithms Chapter 5: The Tree Searching Strategy - Examples 1 / 11 Chapter 5: The Tree Searching Strategy 1. Ex 5.1Determine the satisfiability of the following Boolean formulas by depth-first search

More information

Scheduling with AND/OR Precedence Constraints

Scheduling with AND/OR Precedence Constraints Scheduling with AND/OR Precedence Constraints Seminar Mathematische Optimierung - SS 2007 23th April 2007 Synthesis synthesis: transfer from the behavioral domain (e. g. system specifications, algorithms)

More information

Greedy Algorithms and Data Compression. Curs 2018

Greedy Algorithms and Data Compression. Curs 2018 Greedy Algorithms and Data Compression. Curs 2018 Greedy Algorithms A greedy algorithm, is a technique that always makes a locally optimal choice in the myopic hope that this choice will lead to a globally

More information

Lecture 2: MergeSort. CS 341: Algorithms. Thu, Jan 10 th 2019

Lecture 2: MergeSort. CS 341: Algorithms. Thu, Jan 10 th 2019 Lecture 2: MergeSort CS 341: Algorithms Thu, Jan 10 th 2019 Outline For Today 1. Example 1: Sorting-Merge Sort-Divide & Conquer 2 Sorting u Input: An array of integers in arbitrary order 10 2 37 5 9 55

More information

Geometric Steiner Trees

Geometric Steiner Trees Geometric Steiner Trees From the book: Optimal Interconnection Trees in the Plane By Marcus Brazil and Martin Zachariasen Part 3: Computational Complexity and the Steiner Tree Problem Marcus Brazil 2015

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

Theory of Computation

Theory of Computation Theory of Computation (Feodor F. Dragan) Department of Computer Science Kent State University Spring, 2018 Theory of Computation, Feodor F. Dragan, Kent State University 1 Before we go into details, what

More information

Pruning digraphs for reducing catchment zones

Pruning digraphs for reducing catchment zones Pruning digraphs for reducing catchment zones Fernand Meyer Centre de Morphologie Mathématique 19 March 2017 ernand Meyer (Centre de Morphologie Mathématique) Pruning digraphs for reducing catchment zones

More information

Algorithms and Theory of Computation. Lecture 13: Linear Programming (2)

Algorithms and Theory of Computation. Lecture 13: Linear Programming (2) Algorithms and Theory of Computation Lecture 13: Linear Programming (2) Xiaohui Bei MAS 714 September 25, 2018 Nanyang Technological University MAS 714 September 25, 2018 1 / 15 LP Duality Primal problem

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

IS 2610: Data Structures

IS 2610: Data Structures IS 2610: Data Structures Graph April 12, 2004 Graph Weighted graph call it networks Shortest path between nodes s and t in a network Directed simple path from s to t with the property that no other such

More information

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.

Analysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes. Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci

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

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

On shredders and vertex connectivity augmentation

On shredders and vertex connectivity augmentation On shredders and vertex connectivity augmentation Gilad Liberman The Open University of Israel giladliberman@gmail.com Zeev Nutov The Open University of Israel nutov@openu.ac.il Abstract We consider the

More information

A Minimum Spanning Tree for the #2SAT Problem

A Minimum Spanning Tree for the #2SAT Problem A Minimum Spanning Tree for the #2SAT Problem Guillermo De Ita, Meliza Contreras, Pedro Bello Faculty of Computer Science, Universidad Autónoma de Puebla {deita,mcontreras,pbello}@cs.buap.mx Abstract.

More information

OpenFst: An Open-Source, Weighted Finite-State Transducer Library and its Applications to Speech and Language. Part I. Theory and Algorithms

OpenFst: An Open-Source, Weighted Finite-State Transducer Library and its Applications to Speech and Language. Part I. Theory and Algorithms OpenFst: An Open-Source, Weighted Finite-State Transducer Library and its Applications to Speech and Language Part I. Theory and Algorithms Overview. Preliminaries Semirings Weighted Automata and Transducers.

More information

4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd

4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd 4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd Data Compression Q. Given a text that uses 32 symbols (26 different letters, space, and some punctuation characters), how can we

More information

7.5 Bipartite Matching

7.5 Bipartite Matching 7. Bipartite Matching Matching Matching. Input: undirected graph G = (V, E). M E is a matching if each node appears in at most edge in M. Max matching: find a max cardinality matching. Bipartite Matching

More information

UNIVERSITY OF PUNE, PUNE BOARD OF STUDIES IN MATHEMATICS SYLLABUS. F.Y.BSc (Computer Science) Paper-I Discrete Mathematics First Term

UNIVERSITY OF PUNE, PUNE BOARD OF STUDIES IN MATHEMATICS SYLLABUS. F.Y.BSc (Computer Science) Paper-I Discrete Mathematics First Term UNIVERSITY OF PUNE, PUNE 411007. BOARD OF STUDIES IN MATHEMATICS SYLLABUS F.Y.BSc (Computer Science) Paper-I Discrete Mathematics First Term 1) Finite Induction (4 lectures) 1.1) First principle of induction.

More information

Data Structures for Disjoint Sets

Data Structures for Disjoint Sets Data Structures for Disjoint Sets Advanced Data Structures and Algorithms (CLRS, Chapter 2) James Worrell Oxford University Computing Laboratory, UK HT 200 Disjoint-set data structures Also known as union

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

More on NP and Reductions

More on NP and Reductions Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600 127, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 501 Advanced Data

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

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

Discrete Optimization Lecture 5. M. Pawan Kumar

Discrete Optimization Lecture 5. M. Pawan Kumar Discrete Optimization Lecture 5 M. Pawan Kumar pawan.kumar@ecp.fr Exam Question Type 1 v 1 s v 0 4 2 1 v 4 Q. Find the distance of the shortest path from s=v 0 to all vertices in the graph using Dijkstra

More information

B.C.S.Part I Mathematics (Sem.- I & II) Syllabus to be implemented from June 2013 onwards.

B.C.S.Part I Mathematics (Sem.- I & II) Syllabus to be implemented from June 2013 onwards. B.C.S.Part I Mathematics (Sem.- I & II) Syllabus to be implemented from June 2013 onwards. 1. TITLE: Subject Mathematics 2. YEAR OF IMPLEMENTATION : Revised Syllabus will be implemented from June 2013

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

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Before we show how languages can be proven not regular, first, how would we show a language is regular? CS35 Proving Languages not to be Regular Before we show how languages can be proven not regular, first, how would we show a language is regular? Although regular languages and automata are quite powerful

More information

Correctness of Dijkstra s algorithm

Correctness of Dijkstra s algorithm Correctness of Dijkstra s algorithm Invariant: When vertex u is deleted from the priority queue, d[u] is the correct length of the shortest path from the source s to vertex u. Additionally, the value d[u]

More information

CS60007 Algorithm Design and Analysis 2018 Assignment 1

CS60007 Algorithm Design and Analysis 2018 Assignment 1 CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in

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

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

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

2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures

2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures 2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures Instructor: Broňa Brejová E-mail: brejova@fmph.uniba.sk Office: M163 Course webpage: http://compbio.fmph.uniba.sk/vyuka/vpds/

More information

Chapter 8 Dynamic Programming

Chapter 8 Dynamic Programming Chapter 8 Dynamic Programming Copyright 007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by

More information

CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 17: Combinatorial Problems as Linear Programs III. Instructor: Shaddin Dughmi

CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 17: Combinatorial Problems as Linear Programs III. Instructor: Shaddin Dughmi CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 17: Combinatorial Problems as Linear Programs III Instructor: Shaddin Dughmi Announcements Today: Spanning Trees and Flows Flexibility awarded

More information

(v,w) disconnected? bridge? articulatiion point? Update MST during insertion and deletion

(v,w) disconnected? bridge? articulatiion point? Update MST during insertion and deletion Dynamic graph algorithms with applications Mikkel Thorup AT&T Labs{Research Dynamic data structures in static problems Standard example: priority queue in greedy algorithm such as Dijkstra's single source

More information