Algorithmic Discrete Mathematics 6. Exercise Sheet

Similar documents
Randomized Perfect Bipartite Matching

Graphs III - Network Flow

Network Flows: Introduction & Maximum Flow

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow.

1 Motivation and Basic Definitions

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Reminder: Flow Networks

Matching. Slides designed by Kevin Wayne.

18 Extensions of Maximum Flow

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t)

Algorithm Design and Analysis

Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov)

Main Reference: Sections in CLRS.

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises

Network Flow. Data Structures and Algorithms Andrei Bulatov

Today: Max Flow Proofs

Introduction to Congestion Games

CS 473G Lecture 15: Max-Flow Algorithms and Applications Fall 2005

Soviet Rail Network, 1955

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem

CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it

Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network.

Maximum Flow and Minimum Cut

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques

CSE 521: Design & Analysis of Algorithms I

16 Max-Flow Algorithms and Applications

Soviet Rail Network, 1955

Network Flows UPCOPENCOURSEWARE number 34414

Maximum Flow in Planar Graphs

Algorithm Design and Analysis

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges.

Average Case Lower Bounds for Monotone Switching Networks

EECE 301 Signals & Systems Prof. Mark Fowler

2. VECTORS. R Vectors are denoted by bold-face characters such as R, V, etc. The magnitude of a vector, such as R, is denoted as R, R, V

Notes on cointegration of real interest rates and real exchange rates. ρ (2)

Homework sheet Exercises done during the lecture of March 12, 2014

CHAPTER 7: SECOND-ORDER CIRCUITS

SOLUTIONS TO ECE 3084

Stationary Distribution. Design and Analysis of Algorithms Andrei Bulatov

Sample Final Exam (finals03) Covering Chapters 1-9 of Fundamentals of Signals & Systems

Longest Common Prefixes

Exponential Sawtooth

PHYSICS Solving Equations

Introduction to SLE Lecture Notes

6.302 Feedback Systems Recitation : Phase-locked Loops Prof. Joel L. Dawson

Notes for Lecture 17-18

They were originally developed for network problem [Dantzig, Ford, Fulkerson 1956]

To become more mathematically correct, Circuit equations are Algebraic Differential equations. from KVL, KCL from the constitutive relationship

Physics 240: Worksheet 16 Name

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a.

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem.

Discussion Session 2 Constant Acceleration/Relative Motion Week 03

18.03SC Unit 3 Practice Exam and Solutions

PHYSICS 151 Notes for Online Lecture #4

23 Maximum Flows and Minimum Cuts

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2

How to Solve System Dynamic s Problems

Electrical and current self-induction

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

arxiv: v1 [cs.cg] 21 Mar 2013

CONTROL SYSTEMS. Chapter 10 : State Space Response

Today s topics. CSE 421 Algorithms. Problem Reduction Examples. Problem Reduction. Undirected Network Flow. Bipartite Matching. Problem Reductions

Inventory Analysis and Management. Multi-Period Stochastic Models: Optimality of (s, S) Policy for K-Convex Objective Functions

16 Max-Flow Algorithms

THE BERNOULLI NUMBERS. t k. = lim. = lim = 1, d t B 1 = lim. 1+e t te t = lim t 0 (e t 1) 2. = lim = 1 2.

The Arcsine Distribution

5.2 GRAPHICAL VELOCITY ANALYSIS Polygon Method

Geometric Path Problems with Violations

Chapter 7: Inverse-Response Systems

u(t) Figure 1. Open loop control system

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Please Complete Course Survey. CMPSCI 311: Introduction to Algorithms. Approximation Algorithms. Coping With NP-Completeness. Greedy Vertex Cover

Seminar 4: Hotelling 2

Some Ramsey results for the n-cube

Predator - Prey Model Trajectories and the nonlinear conservation law

Homework-8(1) P8.3-1, 3, 8, 10, 17, 21, 24, 28,29 P8.4-1, 2, 5

6.8 Laplace Transform: General Formulas

CHAPTER 12 DIRECT CURRENT CIRCUITS

Best test practice: Take the past test on the class website

Laplace Transform. Inverse Laplace Transform. e st f(t)dt. (2)

CSE 421 Introduction to Algorithms Winter The Network Flow Problem

3/3/2015. Chapter 7. Network Flow. Maximum Flow and Minimum Cut. Minimum Cut Problem

Network Flow Applications

FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER

Designing Information Devices and Systems I Spring 2019 Lecture Notes Note 17

Mon Apr 2: Laplace transform and initial value problems like we studied in Chapter 5

Chapter 3 Boundary Value Problem

Dynamic Programming 11/8/2009. Weighted Interval Scheduling. Weighted Interval Scheduling. Unweighted Interval Scheduling: Review

Position, Velocity, and Acceleration

On the N P-hardness of GRacSim drawing

26.1 Flow networks. f (u,v) = 0.

KINEMATICS IN ONE DIMENSION

Topics in Combinatorial Optimization May 11, Lecture 22

Price of Stability and Introduction to Mechanism Design

Math 333 Problem Set #2 Solution 14 February 2003

arxiv: v2 [cs.cg] 30 Apr 2015

Transcription:

Algorihmic Dicree Mahemaic. Exercie Shee Deparmen of Mahemaic SS 0 PD Dr. Ulf Lorenz 7. and 8. Juni 0 Dipl.-Mah. David Meffer Verion of June, 0 Groupwork Exercie G (Heap-Sor) Ue Heap-Sor wih a min-heap o or he array (,,,,, 9, ). Fir ep i o conruc he heap. Thi can be done by uing buildheap or ju inering all number and ue heapify afer each inerion. So we ge a heap where he minimal elemen i he roo. We exrac hi roo, pu i in a new array and pu he elemen on he righ boom of he heap o he roo. Now he heap propery will in general be violaed. Therefore we ue heapify o regain ha propery. The big roo elemen ink down ino he heap. Now he malle elemen of he remainig elemen i he roo of he heap and he procedure ar from he beginning. We do hi ill our heap i empy. Then our array i ored. For hi pecial li he iniial heap i of he form (,,,,, 9, ). (Fir: roo, econd: lef child of roo, hird: righ child roo, fourh: lef child of lef child of roo,... ) We exrac he elemen and become he new roo, o we ge he remaining heap (,,,,, 9). We wap and and and by uing heapify and ge o (,,,,, 9). The re of he oring proce work he ame way a before. Exercie G (Maximal flow) Le D = (V, E) be a direced graph wih ource and ink. The capaciie on he edge hould be naural number and he maximal flow x from o i given. Now we wan o modify he capaciy of one edge in he graph by (a) increaing i by, (b) decreaing i by. Give an algorihm ha calculae he maximal flow from o in ha changed graph in O( V + E ). (a) If we increae he capaciy of one edge by hen we ju need o verify if here i an augmening pah in he changed graph. Since we only increaed one edge be he maximal flow can only increae by. Checking if here i a augmening pah can be done by uing DFS which i O( V + E ). (b) If we decreae he capaciy of one edge by here can be wo differen cae..cae: The flow i ill valid and doe no exceed any capaciy on a edge in he graph. Then he maximal flow ju ay he ame..cae: The flow exceed he capaciy on he edge we decreaed he capciy of. We denoe hi edge by (u, v ). Now le P be pah from o u and P be a pah from v o. Thi pah hould be dijoin and only conain edge wih a poiive acual flow. Such pah do exi, ince oherwie here would be no flow on he edge (u, v ) and can be found by uing DFS again. So he runime i O( V + E ) for finding boh of hee pah. Now reduce he flow on he whole pah P (u, v )P by, o he general flow for he graph i valid again, wih a maximal flow reduced by. I could be he cae now ha hi i no he maximal flow, bu we know ha he maximal flow can only be one flow uni bigger han he acual flow. So we ju look for anoher augmening pah a in par (a) and ge he maximal flow for he changed graph. Thi can be done in O( V + E ). Since we did algorihm ep wih O( V + E ) he whole procedure i in O( V + E ). Exercie G (Menger Theorem) (a) A direced graph D = (V, E) i called rongly k-conneced, if for every pair of verice (u, v ) and every e of edge B E wih B k, here exi a direced pah from u o v in D = (V, E \ B). Prove he edge verion of Menger

Theorem. Menger Theorem for edge: A direced graph D = (V, E) i rongly k-conneced, iff for every pair of verice (, ) here exi a lea k direced pah from o which hare no edge. (b) A direced graph D = (V, E) i called k-verex-conneced, if for every pair of verice (u, v ) and every e of verice W V wih W k here exi a direced pah from u o v in D W. Prove he verex verion of Menger Theorem. Menger Theorem for verice: A direced graph D = (V, E) i k-verex-conneced, iff for every pair of verice (, ) here exi a lea k direced pah from o haring no verice. (c) Do Menger Theorem alo hold for undireced graph? (a) : We how ha D i rongly k-conneced implie he exiance of he k direced pah having dijoin edge fir. We do i by howing he following equivalen aemen: There exi verice, uch ha here are a mo k direced pah from o having dijoin edge D i no rongly k-conneced. So le (, ) be uch a pair of verice a decribed above wih a mo k direced pah. We e he capaciy of all edge o and look for flow from o. The maximal flow we ge by hi procedure can be inepreed a he number of direced pah from o having dijoin edge. Now we ue he Max-Flow-Min-Cu Theorem o ge a cu (S, S). The value of ha cu i a mo k, ince he maximal flow can be a mo k. Now we e B a he e of all edge in D connecing S and S. By he previou argumenaion B k. Now we delee all edge in he e B from D. By he cu propery of (S, S) here can be any more direced pah from o in (V, E \ B). Hence D i no rongly k-conneced. : We how ha he exiance of k direced pah from o for arbiary verice, yield ha D i rongly k-conneced. So le D be uch a graph and, V. For any ube B E wih B k we can only delee edge of a mo k direced pah having dijoin edge. So here remain a lea one more direced pah from (, ) which did no ue any of he edge in B. So he graph D i rongly k-conneced. (b) : We wan o how ha for every k-verex-conneced graph D and verice, V here exi a lea k direced pah from o haring no verice. Again we how he following equivalen aemen: If here exi verice, V where we don have k direced pah from o haring no verice, hen D i no k-verex-conneced. So le, V be uch verice, where we have a mo k direced pah from o haring no verice. A in par (a) we wan o ue he Max-Flow-Min-Cu Theorem. Therefore we double each verex i V and name he verice i and i. All edge which where direced o i now are direced o i and all edge which ared in i now ar in i. Addiionally we add edge from i o i wih capaciy. All oher edge ge capaciy.we call hi graph D. Now we deermine he maximal flow f from o in D. Thi flow equal he number of direced pah from o in he orginal graph, which hare no verice. Therefore we inroduced he doubling of all he verice. By he Min-Cu-Max-Flow Theorem we find a cu (S, S) in D wih value f. Now le U be he e of all edge in he minimal cu (S, S). Thi e U conain an edge (i, i ) for every pah from o and all hee edge correpond o a verex i in he orginal graph D. So deleing all edge of B in D i like deleing he correponding verice in D. We call hi verex e W. Since by aumpion B k we ge W k, o we may delee hi verex e in order o look for k-verex-conneciviy. By conrucion here i no more direced pah from o in D \ B. By ranlaing hi o he verex eing we conclude ha here exi no more direced pah from o in our graph D \ W. Thi mean our graph D i no k-verex-conneced. : Le D be a direced graph where for each pair of verice, V here exi a lea k direced pah from o, haring no verice. So we delee any verex e W V from D wih W k. In he wor cae we deleed a verex fromk differen pah from o. Since all hoe pah do no hare verice here mu be a lea one more pah where we did no delee any verex from. So here i a lea one direced pah in D W. Thi mean D i k-verex-conneced. (c) We did no ue ha our graph we worked wih i direced, o he proof work he ame way for undireced graph. We ju have o ubiue direced wih undireced a every place here. Homework Exercie H Look a he following varian of he quickor algorihm. Algorihm QuickSor(a,l,r) (0 poin)

Inpu: An array a of lengh n wih a[i], lower and upper bound l, r wih l r n. Oupu: The array a wih a[l] a[l + ]... a[r]. () Se i = l and j = r. () While i < j Do () Do i = i + While a[i] a[r]. () Do j = j - While (a[ j] a[r] and j i). () If j > i Then Swap a[ j] and a[i]. () End While (7) Swap a[i] and a[r]. (8) If l < i Then QuickSor (a, l, i ). (9) If i + < r Then QuickSor (a, i +, r). (0) reurn a. The ieraion ar by uing QuickSor(a,,lengh(a)). (a) Ue Quickor o or he number array (,, 8,,,, 9,,,, 7). (b) How doe a number array have o look like, o ha Quickor ha a runime of O(n )/O(n log n). Decribe i in general and give an example for boh cae by uing he fir 0 naural number. (a) We give a decripion wha happen while uing Quickor. In he fir run we wap and, 8 and, and and finally 9 and 7. Then 7 i already a he righ place in he array. A ha poin in he algorihm he array i given by (,,,,,, 7,, 8,, 9). Now we have o or he remaining lef and ride ide of he number 7. We do i for he lef ide. The righ ide work he ame way. The array (,,,,, ) become (,,,,, ) Now i a he righ place. The nex ep we wap and. So (,,,, ) become (,,,, ). The array () wih one elemen i already ored and he oher array (,, ) ill need hree Quickor ep where alway he elemen on he righ ide of he array i deleed ill he elemen i he la one lef. In hoe la ep no more wap are involved. Afer doing he ame hing wih he righ par (, 8,, 9) we ge he li (,,,,,, 7, 8, 9,, ). (b) The wor cae for Quickor, uch ha i ha runime O(n ) i a already ored li. Thi way he elemen on he righ hand ide alway ay here and Quickor i ued wih a li wih only one le elemen han before. So we need n Quickor ieraion. An example would be (,,,,,, 7, 8, 9, 0). If we wan a runime of O(n log n) for Quickor we have o pli he li of number in half every ime. Thi way we only have o do half of comparion of he ep before. An example i (,,,, 8,, 7, 0, 9, ).

Exercie H7 (Finding maximal flow) Find he maximal flow from o in he following direced graph and prove i maximaliy. (0 poin) The maximal flow i given by. One can proof ha by he minimal cu which coni of S = {,,,, } and S = {, }. Anoher way o do i i o ue he Ford-Fulkeron algorihm and find augmening pah ill here are no more lef. One poible oluion i: / / 0/ / / / / / / / / / / / Exercie H8 (Righ or Wrong?) (0 poin) Le D = (V, E) be a direced graph wih ineger capaciie C e for he edge e E. Le be he ource in hi graph and he ink. Which of he following aemen are righ? Which are wrong? Give a proof or a counerexample. (a) If all capaciie are even, hen here exi a maximal flow f from o, uch ha f (e) i even for all edge e E. (b) If all capaciie are odd, hen here exi a maximal flow f from o, uch ha f (e) i odd for all edge e E. (c) If f i a maximal flow from o, hen eiher f (e) = 0 or f (e) = c e hold for all edge e E. (d) There exi a maximal flow from o, uch ha eiher f (e) = 0 or f (e) = c e hold for all edge e E. (e) If all capaciie on he edge are differen, hen he minimal cu i unique. (f) If we muliply each capaciy wih he poiive real number λ +, hen every minimal cu in here original graph i a minimal cu in he modified graph. (g) If we add he poiive number λ + o each capaciy, hen every minimal cu in he orginal graph i a minimal cu in he modified graph.

/0 / 80 /0 / 00 7 Figure : graph Figure : graph (a) Thi aemen i rue. A he beginning he flow f = 0 i even. Every ime we find an augmening pah i add an even flow o all edge in ha pah ince all capaciie are even. The reuling graph afer ha augmening proce ill ha even capaciie ince we ubraced only even number from even number. So by inducion here i a maximal flow uch ha all flow on he edge are even. (b) Thi aemen i wrong. Look a he graph D wih V = {,,, u, }, E = {(, ), (, ), (, u), (, u), (u, )}. The capaciie for hoe edge hould be excep for he edge (u, ) wih capaciy. So all capaciie are odd, bu he maximal i wih f (u,) =. (c) Thi aemen i wrong, ee graph for a counerexample. (d) Thi aemen i wrong again, ee Graph for counerexample, ince here only exi one poible maximal flow graph which doe no fulfil he needed condiion. (e) Thi aemen i wrong, ee graph for a counerexample. A minimal cu ha value 0 bu here are wo cu namely ({}, {,,, }) and ({,,, }, {}) having ha value. (f) Thi aemen i righ. We denoe he value of a cu W by c(δ + (W )). Thi mean we um up he value of all edge going from verice in W o W = V \ W. Le S be a minimal cu, o we have c(δ + (S)) c(δ + (W )) for all cu W. In he changend graph (D = (V, E), ĉ) wih λ + we ge ĉ(δ + (S)) = λ c(δ + (S)) λ c(δ + (W )) = ĉ(δ + (W )) for all cu W. So S i ill a minimal cu in he graph (D = (V, E), ĉ). (g) Thi aemen i wrong, a we can ee be looking a graph again. A we have een here a wo cu ({}, {,,, }) and ({,,, }, {}) wih value 0. If we add for example o every edge hen ({}, {,,, }) would ill be minimal wih value. The cu ({,,, }, {}) would have value and herefore would no be minimal anymore.