Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.

Slides:



Advertisements
Similar presentations
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Advertisements

October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
 2004 SDU Lecture9- Single-Source Shortest Paths 1.Related Notions and Variants of Shortest Paths Problems 2.Properties of Shortest Paths and Relaxation.
NP-Complete Problems Polynomial time vs exponential time
Breadth-First Search of Graphs Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
1 Review of some graph algorithms Graph G(V,E) (Chapter 22) –Directed, undirected –Representation Adjacency-list, adjacency-matrix Breadth-first search.
1 Minimizing Movement Erik D. Demaine, MohammadTaghi Hajiagahayi, Hamid Mahini, Amin S. Sayedi-Roshkhar, Shayan Oveisgharan, Morteza Zadimoghaddam SODA.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
MIN-COST ABORESCENCES YQ Lu. Aborescence Definition: Given a directed graph G=(V,E) and a root r, an aborescence rooted at r is a subgraph T that each.
CS138A Network Flows Peter Schröder. CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v)
1 Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a 1, a 2, …, a n } and a size.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Graphs and Trees This handout: Trees Minimum Spanning Tree Problem.
1 Assignment 4. This one is cancelled since there is a solution on website. I new assignment will be given on Nov. 28. (Due on Friday of Week 14. Drop.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
1 More On Dynamic programming Algorithms Shortest path with edge constraint: Let G=(V, E) be a directed graph with weighted edges. Let s and v be two vertices.
The max flow problem
1 Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a 1, a 2, …, a n } and a size.
CSE 780 Algorithms Advanced Algorithms SSSP Dijkstra’s algorithm SSSP in DAGs.
Online Data Gathering for Maximizing Network Lifetime in Sensor Networks IEEE transactions on Mobile Computing Weifa Liang, YuZhen Liu.
1 NP-Complete Problems Polynomial time vs exponential time –Polynomial O(n k ), where n is the input size (e.g., number of nodes in a graph, the length.
Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a1, a2, …, an} and a size s(a)
1 Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 5 Tuesday, 10/7/08 Graph Algorithms: Part 2.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 5 Wednesday, 10/4/06 Graph Algorithms: Part 2.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
1 NP-Complete Problems (Fun part) Polynomial time vs exponential time –Polynomial O(n k ), where n is the input size (e.g., number of nodes in a graph,
MAX FLOW CS302, Spring 2013 David Kauchak. Admin.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Minimum weight spanning trees
Introduction to Algorithms Jiafen Liu Sept
The single-source shortest path problem (SSSP) input: a graph G = (V, E) with edge weights, and a specific source node s. goal: find a minimum weight (shortest)
1 WEEK 11 Graphs III Network Flow Problems A Simple Maximum-Flow Algorithm Izmir University of Economics.
Algorithm Design and Analysis (ADA)
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Chapter 22: Elementary Graph Algorithms III. 2 About this lecture Topological Sort.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
11/21/02CSE Max Flow CSE Algorithms Max Flow Problems.
Instructor Neelima Gupta Edited by Divya Gaur(39, MCS '09) Thanks to: Bhavya(9), Deepika(10), Deepika Bisht(11) (MCS '09)
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Trees.
Network flow problem [Adapted from M.Chandy].
Chapter 5. Optimal Matchings
Maximum flow: The preflow/push method of Goldberg and Tarjan (87)
Instructor: Shengyu Zhang
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Basic Graph Algorithms
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Chapter 24: Single-Source Shortest Paths
Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a1, a2, …, an} and a size s(a)
Chapter 24: Single-Source Shortest Paths
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Advanced Graph Homer Lee 2013/10/31.
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question 1. (20 points) Give an O(n 2 ) dynamic algorithm to find the longest monotonically increasing subsequence of a sequence of n numbers. (Assume that each integer appears once in the input sequence of n numbers) Example: Consider sequence 1,8, 2,9, 3,10, 4, 5. Both subsequences 1, 2, 3, 4, 5 and 1, 8, 9, 10 are monotonically increasing subsequences. However, 1,2,3, 4, 5 is the longest.

Assignment 4. (Due on Dec 2. 2:30 p.m.) Question 2. (40 points) Give an O(n 2 ) dynamic algorithm to find the longest monotonically increasing subsequence of a sequence of n numbers, where an odd number in the monotonically increasing subsequence must be followed by an even number. Example: Consider sequence 1,7,8, 2,9, 3,10, 4, 5. Both subsequences 1, 2, 3, 4, 5 and 1, 8, 9, 10 are monotonically increasing subsequences. However, 1,2,3, 4, 5 is not the one that we are looking for since 5 is not followed by an even number.

Assignment 4. (Due on Dec 2. 2:30 p.m.) Question 3 (40 points) Let T be a rooted binary tree, where each internal node in the tree has two children and every node (except the root) in T has a parent. Each leaf in the tree is assigned a letter in  ={A, C, G, T}. Figure 1 gives an example. Consider an edge e in T. If every end of e is assigned a letter, then the cost of e is 0 if the two letters are identical and the cost is 1 if the two letters are not identical. The problem here is to assign a letter in  to each internal node of T such that the cost of the tree is minimized, where the cost of the tree is the total cost of all edges in the tree. Design a polynomial-time dynamic programming algorithm to solve the problem.

A A C Figure 1

Lemma 26.8: If the Edmonds-Karp algorithm is run on a flow network G=(V,E) with source s and sink t, then for all vertices v  V-{s, t}, the shortest-path distance  f (s,v) in the residual network G f increases monotonically with each flow augmentation. Proof: We prove it by contradiction. Let f and f’ be the flows for the k-th and (k+1)-th iterations, the augmentation between them is the first that decrease some shortest-path distance. Let v be the vertex with minimum  f’ (s,v) such that  f’ (s,v)<  f (s,v).

Let P: s -- … u->v be the shortest path in G f’. Thus, (u,v)  E f’ and  f’ (s,u)=  f’ (s,v)-1. By the choice of v,  f’ (s,u)   f (s,u). Thus, (u,v)  E f. (Otherwise, we have  f (s,v)   f (s,u)+1   f’ (s,u)+1 =  f’ (s,v). ) How can we have (u,v)  E f’ and (u,v)  E f. ? The augmentation must have increased the flow form v to u.

Since E-K algorithm always uses shortest path, edge (v, u) is the last edge in the path from s to u. So,  f (s,v)=  f (s,u)-1   f’ (s,u)-1 =  f’ (s,v)-2. Contradiction to  f’ (s,v)<  f (s,v).

Theorem If Edmonds-Karp algorithm is run on a flow network G=(V,E) with source and sink t, then the total number of flow augmentations performed by the algorithm is O(VE). Proof: Each augmentation has a critical edge (u, v), where c(u,v) is minimum among all edges in the shortest path. We show that each edge (u,v) can be a critical edge for at most O(|V|) times. Consider a critical edge (u,v) for flow f.  f (s,v)=  f (s,u)+1. (u,v) will disappear after that path is used for augmentation.

(u,v) will appear again after an augmentation with (v,u) in the shortest path. Let f’ be the flow in G when this event occurs, we have  f’ (s,u)=  f’ (s,v)+1. Thus,  f’ (s,u)=  f’ (s,v)+1   f (s,v)+1=  f (s,u)+2. Since the length of the shortest path is at most |V|-1. Thus, each edge (u,v) can be a critical edge for at most |O(|V|) times. Total number of augmentations is O(VE). Each iteration takes at most O(E) time, the total time is O(VE 2 ).

Maximum k-Clustering Problem: Given a set of points V in the plane (or some other metric space), find k points c 1, c 2,.., c k such that for each v in V, min { i=1, 2, …, k} d(v, s i )  d and d is minimized.

Fasthest-point clustering algorithm Step 1: arbitrarily select a point in V as c 1. Step 2: let i=2. Step 3: pick a point c i from V –{c 1, c 2, …, c i-1 } to maximize min {|c 1 c i |, |c 2 c i |,…,|c i-1 c i |}. Step 4: i=i+1; Step 5: repeat Steps 3 and 4 until i=k.

Theorem: Farthest-point clustering algorithm has ratio-2. Proof: Let c k+1 be an point in V that maximize  =min {|c 1 c k+1 |, |c 2 c k+1 |,…,|c k c k+1 |}. Since two of the k+1 points must be in the same group,  <=2opt. Since for any v in V, min {|c 1 v|, |c 2 v|,…,|c k v|}<=  (based on the alg.), so the algorithm has ratio-2.