h2sol - CO 227 Homework assignment 2 Fall ‘10 Page 1 CO...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CO 227 - Homework assignment 2 Fall ‘10 Page 1 CO 227 - Fall ‘10 Homework assignment #2: (Due at the beginning of the class, 10:30AM, on Wednesday, Oct 13th) Instructions: • Please show all your work and justify your answers. Answers without proper justification will not be considered. • Please list who you collaborated with. • Please staple your homework and write your name and student id in pen. • Total value = 100 points Question 1- Algorithms (20 points) Consider a general IP, where all variables are restricted to be { , 1 } . min c T x s.t. Ax ≤ b x ∈ { , 1 } n Now consider the following algorithm to solve this problem: For all possible values of x that satisfy Ax ≤ b and x ∈ { , 1 } n , compute c T x and find the minimum among all possible choices. (a) (10 points) Give an upper bound on the running time of the algorithm (as a function of n ). Solution: Assumption: A is a m × n matrix; hence b is of size m . There size of the set { , 1 } n is 2 n , i.e. we have 2 n possible choices for x . For each x we need to compute Ax (denoted by y in the pseudocode) and check wether it is ≤ b , so the outline of the algorithm would be: Let Opt = ∞ , for p = 1 ,..., 2 n repeat: 1. for 1 ≤ i ≤ m 2. let y i = 0 3. for 1 ≤ j ≤ n 4. y i = y i + A ij x j 5. end for 6. end for 7. if y < b 8. let Obj = 0 9. for 1 ≤ i ≤ n 10. Obj = Obj + c i x i 11. end for 12. if Obj < Opt CO 227 - Homework assignment 2 Fall ‘10 Page 2 13. Opt = Obj 14. x * = x 15. end if 16. end if Lines 1-6 computes Ax ; the running time of it would be m (3 n + m ), since we have: • m assignment in line 2 • 3 n for lines 2-5; the 3 represents 1 assignment, 1 addition and 1 multiplication in line 4. Line 7 needs m comparisons. Line 8 has 1 assignment. Lines 9-11 has running time of 3 n (1 assignment, 1 multiplication, 1 addition in line 10). Lines 12-14 has running time of n + 2 • 1 comparison in line 12 • 1 assignment in line 13 • n assignments in line 14 Adding all the above, we get the running time of p ( n ) = m [3 n + m + 1] + 4 n + 3. To check all possible x ’s, this algorithm has at most the running time of 2 n p ( n ). Your pseudocode, and hence your p ( n ) may be different; any correct solution is accepted. (b) (10 points) Give a lower bound on the running time of the algorithm that is exponential on n , that is, provide an example of an instance for which the algorithm must make at least t n operations for some real number t . Solution: An example can be: min e T x s.t. x ∈ { , 1 } n where e is the vector of all ones. Any other model in which all possible x ’s satisfy the constraints (hence you need to check them all and compute the objective value for all of them) would work. The lower bound on the running time that is exponential in n would be only checking the objective value for all possible combinations for...
View Full Document

This note was uploaded on 01/18/2011 for the course CO 227 taught by Professor 1 during the Spring '10 term at Waterloo.

Page1 / 8

h2sol - CO 227 Homework assignment 2 Fall ‘10 Page 1 CO...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online