Introduction to Discrete Optimization

Similar documents
Discrete Optimization

ICS 252 Introduction to Computer Design

Discrete Optimization 2010 Lecture 3 Maximum Flows

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

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

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

Arc Length and Surface Area in Parametric Equations

MATH 162. FINAL EXAM ANSWERS December 17, 2006

CIS 121 Data Structures and Algorithms with Java Spring Big-Oh Notation Monday, January 22/Tuesday, January 23

Sample Final Questions: Solutions Math 21B, Winter y ( y 1)(1 + y)) = A y + B

Math 1B Final Exam, Solution. Prof. Mina Aganagic Lecture 2, Spring (6 points) Use substitution and integration by parts to find:

CSE 417: Algorithms and Computational Complexity

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

Fundamental Algorithms

Fundamental Algorithms

Data selection. Lower complexity bound for sorting

Math Test #3 Info and Review Exercises

Upper Bounds of Dynamic Chromatic Number

Enumerate all possible assignments and take the An algorithm is a well-defined computational

18.01 Single Variable Calculus Fall 2006

HOMEWORK SOLUTIONS MATH 1910 Sections 6.4, 6.5, 7.1 Fall 2016

Introduction to Differentials

Brownian Motion and Stochastic Calculus

CS 161 Summer 2009 Homework #2 Sample Solutions

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Data Structures and Algorithms

Calculus II - Fall 2013

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

Running Time Evaluation

Mathematical Induction

Lecture 5: Integrals and Applications

Sorting algorithms. Sorting algorithms

Name: SOLUTIONS Date: 11/9/2017. M20550 Calculus III Tutorial Worksheet 8

Multiple Integrals. Chapter 4. Section 7. Department of Mathematics, Kookmin Univerisity. Numerical Methods.

Math 221 Exam III (50 minutes) Friday April 19, 2002 Answers

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

Introduction. How can we say that one algorithm performs better than another? Quantify the resources required to execute:

Design and Analysis of Algorithms

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

Single Source Shortest Paths

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

Practice Final Solutions

Module 1: Analyzing the Efficiency of Algorithms

Algorithms: Lecture 12. Chalmers University of Technology

= π + sin π = π + 0 = π, so the object is moving at a speed of π feet per second after π seconds. (c) How far does it go in π seconds?

1 Quick Sort LECTURE 7. OHSU/OGI (Winter 2009) ANALYSIS AND DESIGN OF ALGORITHMS

Arc Length. Philippe B. Laval. Today KSU. Philippe B. Laval (KSU) Arc Length Today 1 / 12

Past Exam Problems in Integrals, Solutions

Integrals. D. DeTurck. January 1, University of Pennsylvania. D. DeTurck Math A: Integrals 1 / 61

Prelim 1 Solutions V2 Math 1120

2.2 The derivative as a Function

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

Shortest Path Algorithms

New York City College of Technology, CUNY Mathematics Department. MAT 1575 Final Exam Review Problems. 3x (a) x 2 (x 3 +1) 3 dx (b) dx.

Calculus II Practice Test Problems for Chapter 7 Page 1 of 6

D. Correct! This is the correct answer. It is found by dy/dx = (dy/dt)/(dx/dt).

Eigenvalues of 2-edge-coverings

Lecture 5: Loop Invariants and Insertion-sort

CS 4407 Algorithms Lecture: Shortest Path Algorithms

Lecture 4: Best, Worst, and Average Case Complexity. Wednesday, 30 Sept 2009

Assignment 16 Solution. Please do not copy and paste my answer. You will get similar questions but with different numbers!

CSCI 3110 Assignment 6 Solutions

CE 221 Data Structures and Algorithms. Chapter 7: Sorting (Insertion Sort, Shellsort)

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

Parametric Curves. Calculus 2 Lia Vas

Reminder of Asymptotic Notation. Inf 2B: Asymptotic notation and Algorithms. Asymptotic notation for Running-time

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

Practice Final Exam Solutions

Computational Complexity - Pseudocode and Recursions

Lecture 4: Integrals and applications

Integration by Parts

CS781 Lecture 3 January 27, 2011

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

Describe an algorithm for finding the smallest integer in a finite sequence of natural numbers.

Practice Problems for Exam 3 (Solutions) 1. Let F(x, y) = xyi+(y 3x)j, and let C be the curve r(t) = ti+(3t t 2 )j for 0 t 2. Compute F dr.

Connections between exponential time and polynomial time problem Lecture Notes for CS294

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

MAT137 Calculus! Lecture 6

Algorithms and Their Complexity

Chapter 1: Preliminaries and Error Analysis

CSE613: Parallel Programming, Spring 2012 Date: May 11. Final Exam. ( 11:15 AM 1:45 PM : 150 Minutes )

1. If the line l has symmetric equations. = y 3 = z+2 find a vector equation for the line l that contains the point (2, 1, 3) and is parallel to l.

AC64/AT64/ AC115/AT115 DESIGN & ANALYSIS OF ALGORITHMS

Exploring Substitution

The Fast Multipole Method and other Fast Summation Techniques

CSCI Honor seminar in algorithms Homework 2 Solution

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form

Divide and Conquer Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 14

CS383, Algorithms Spring 2009 HW1 Solutions

Topic 6: Calculus Differentiation Markscheme 6.1 Product Quotient Chain Rules Paper 2

PGSS Discrete Math Solutions to Problem Set #4. Note: signifies the end of a problem, and signifies the end of a proof.

More Approximation Algorithms

Definition of Derivative

CS Asymptotic Notations for Algorithm Analysis

Outline. 1 Introduction. 3 Quicksort. 4 Analysis. 5 References. Idea. 1 Choose an element x and reorder the array as follows:

Algorithm efficiency analysis

Mathematics for Decision Making: An Introduction. Lecture 8

Space Complexity of Algorithms

Mat104 Fall 2002, Improper Integrals From Old Exams

Transcription:

Prof. Friedrich Eisenbrand Martin Niemeier Due Date: April 28, 2009 Discussions: April 2, 2009 Introduction to Discrete Optimization Spring 2009 s 8 Exercise What is the smallest number n such that an algorithm A with running time 000000 n 2 is faster than an algorithm B with a running time of 2 n? Let f (n) := 000000 n 2 and g (n) := 2 n. We have f (29) = 84,000,000 and g (29) = 536,870,92, but f (30) = 900,000,000 and g (30) =,073,74,824. Thus n = 30 is the smallest number such that A is faster than B. Exercise 2 Decide which ones of the following statements are true and give a short explanation:. 4n 3 + 3n 2 n 00 = O ( n 3) 2. n = O ( n 7) 3. n 3 00n 2 = Ω(n 4 ) 4. 2 n = O ( n 2) 5. n = O (n) 6. log(n) = O ( n ). Let T (n) := 4n 3 + 3n 2 n 00. If n we have 4n 3 + 3n 2 n 00 7n 3. Thus if we set n 0 := and c := 7, then T (n) cn 3 for each n R 0, n n 0 and thus T (n) = O ( n 3). 2. Let T (n) := n. If n we have n n 7. Thus if we set n 0 := and c :=, then T (n) c n 7 for each n R 0, n n 0 and thus T (n) = O ( n 7).

3. Let T (n) := n 3 00n 2. Assume that T (n) = Ω(n 4 ). Thus there are constants c R 0 and n 0 R 0 such that for each n n 0. Equation () implies for each n n 0. Let n := max{n 0,00}. Then n 3 00n 2 c n 4 () 0 c n 4 + n 3 00n 2 = n 2 (c n 2 + n 00) (2) (n ) }{{} 2 (c (n ) 2 +n }{{}} {{ 00 } ) < 0 >0 >0 0 in contradiction to (2). Thus T (n) = Ω(n 4 ) does NOT hold. 4. Let T (n) := 2 n. Assume that T (n) = O ( n 2). Thus there are constants c R 0 and n 0 R 0 such that 2 n c n 2 = 2 log(c n2) = 2 log(c)+2log(n) for each n n 0. This implies n log(c)+2log(n) and thus f (n) := n+log(c)+2log(n) 0 for each n n 0. Observe that f (n) = + 2 ln(2) n n. f (n ) < 0 wich is a contradition. Thus 2 n O ( n 2). 5. Let T (n) := n = n 2. If n we have n 2 n. Thus there is some n n 0 such that Thus if we set n 0 := and c :=, then T (n) c n for each n R 0, n n 0 and thus T (n) = O (n). 6. Let T (n) := logn and f (n) := n logn. Observe that for each n 0 we have log(n) n if and only if f (n) 0. Then f (n) = n 2 n enough we have ln(a) = n 2 ( n 2 f (n 0 ) 0 and f (n) 0 for all n n 0. Thus log (n) = O ( n ). ln(2) ) n. Thus for some n 0 large Exercise 3 Consider the following algorithm. The input is a sequence of n integers a[],..., a[n]. 2

Require: : for i to n do 2: for j n downto i + do 3: if a[j] < a[j-] then 4: exchange a[j ] a[j ] 5: end if 6: end for 7: end for 8: Output a[],..., a[n]. Give an asymptotic upper bound on the running time of the algorithm (with explanations). What is the output of the algorithm? This algorithm is the so called BUBBLE-SORT algorithm. It sorts the input sequence and outputs it in non-decreasing order. Each execution of the body of the inner loop (line 3-5) takes constant time, since at most two operations (one comparison and one exchange) are carried out. The outer loop is executed n times, and in the i -th invokation, the inner look is executed n i times. Thus in total, the body of the inner loop is executed n n n (n i ) = n i = n 2 n(n + ) 2 i= i= i= = n2 2 n 2 = O ( n 2). Thus an asymptotic upper bound on the running time of the algorithm is O ( n 2). Exercise 4 Consider the following graph: Perform the breath first search algorithm on this graph starting in s. For each node v, give the values π[v] and d[v] at the end of the algorithm. Initialization: 3

d[r ] =, d[s] = 0, d[t] =. d[u] =,d[v] =, d[w] =, d[x] =, d[y] = π[r ] = 0, π[s] = 0, π[t] = 0, π[u] = 0, π[v] = 0, π[w] = 0, π[x] = 0, π[y] = 0. Iteration: d[r ] =, d[s] = 0, d[t] =. d[u] =,d[v] =, d[w] =, d[x] =, d[y] = π[r ] = s, π[s] = 0, π[t] = 0, π[u] = 0, π[v] = 0, π[w] = 0, π[x] = 0, π[y] = 0 2. Iteration: d[r ] =, d[s] = 0, d[t] =. d[u] =,d[v] =, d[w] =, d[x] =, d[y] = π[r ] = s, π[s] = 0, π[t] = s, π[u] = 0, π[v] = 0, π[w] = 0, π[x] = 0, π[y] = 0 3. Iteration: 4

d[r ] =, d[s] = 0, d[t] =. d[u] =,d[v] = 2, d[w] =, d[x] =, d[y] = π[r ] = s, π[s] = 0, π[t] = s, π[u] = 0, π[v] = r, π[w] = 0, π[x] = 0, π[y] = 0 4. Iteration: d[r ] =, d[s] = 0, d[t] =. d[u] =,d[v] = 2, d[w] = 2, d[x] =, d[y] = π[r ] = s, π[s] = 0, π[t] = s, π[u] = 0, π[v] = r, π[w] = t, π[x] = 0, π[y] = 0 5. Iteration: d[r ] =, d[s] = 0, d[t] =. d[u] =,d[v] = 2, d[w] = 2, d[x] = 3, d[y] = π[r ] = s, π[s] = 0, π[t] = s, π[u] = 0, π[v] = r, π[w] = t, π[x] = w, π[y] = 0 6. Iteration: 7. Iteration: d[r ] =, d[s] = 0, d[t] =. d[u] = 4,d[v] = 2, d[w] = 2, d[x] = 3, d[y] = π[r ] = s, π[s] = 0, π[t] = s, π[u] = x, π[v] = r, π[w] = t, π[x] = w, π[y] = 0 5

d[r ] =, d[s] = 0, d[t] =. d[u] = 4,d[v] = 2, d[w] = 2, d[x] = 3, d[y] = 4 π[r ] = s, π[s] = 0, π[t] = s, π[u] = x, π[v] = r, π[w] = t, π[x] = w, π[y] = x Exercise 5 There are two types of professional wrestlers: "good guys" and "bad guys". Between any pair of professional wrestlers, there may or may not be a rivalry. Suppose we have n professional wrestlers and we have a list of r pairs of wrestlers for which there are rivalries. Give an O (n + r )-time algorithm that determines whether it is possible to designate some of the wrestlers as good guys and the remainder as bad guys such that each rivalry is between a good guy and a bad guy. If it is possible to perform such a designation, your algorithm should produce it. Hint: Describe the rivalries as a graph and use an algorithm from the lecture to solve the problem. Let V be the set of wrestlers. Let A := {(u, v) : u, v V,u and v have a rivalry.}. Consider the graph G = (V, A). A set U V is called independent, if there are no arcs between two nodes of U, i.e. for all (uv) A we have u U or v U. Note that a designation of the wrestlers as "good guys" and "bad guys" with no rivalries inside the two groups is equivalent to find a partition of the nodes of G into two sets V and V 2, i.e. V = V V 2 and V V 2 =, such that V and V 2 are independent. Now perform breadth first search starting in any node v V. If there are nodes left that have not been visited in the breadth first search, do another breadth first search starting at one of these nodes. Repeat this until all nodes have been visited. Partition the nodes into two sets V and V 2 defined as follows: V := {v V : d[v] is uneven}. V 2 := {v V : d[v] is even}. Assume that V is not independent. Thus there are two nodes u, v V such that (u, v) A. Let s V be the starting node of the breadth first search. Since d[u] and d[v] are uneven, there is an s u path and an s v path of uneven length in d. By construction of V, for each arc (v, v 2 ) A we have (v 2, v ) A as well. Thus there is an v s-path of uneven length in G as well. Concatenation of the s u-path, the arc (u, v) and the v s-path gives a cycle C in G of uneven length. This shows that it is not possible to partition the nodes of G into two 6

independent sets: However one distributes the nodes of the cycle to the sets V and V 2, at least one pair of "neighbors" will end up in V or V 2. If V 2 is not independent, we can argue analogously that it is not possible to partition the nodes of G into independent sets. Thus, the algorithm described above yields a feasible designation if and only if it is possible to find it. Since the number of nodes in the graph is n and the number of arcs is 2r, its running time is O(n + r ). 7