UML CS Analysis of Algorithms 91.503 (section 201) Fall, 2004 Homework #1 Assigned: Wednesday, 9/8 Due: Wednesday, 9/15 start of lecture This assignment covers textbook material in Chapter 15 (Dynamic Programming) plus review material from 91.404 (undergraduate algorithms). 1. (10 points) Algorithm & Problem Bounds: Let P be a problem. Suppose that the worst-case asymptotic running time complexity of P is in ( n2 lg(n3lgn) ) and is also in O( n3 lg(nlgn)2 ). That is, we know that there exists an algorithm solving P whose worst-case asymptotic running time complexity is in O(n3 lg(nlgn)2) and we know that time proportional to n2 lg(n3lgn) is a lower bound on the worst-case asymptotic running time complexity of any algorithm solving P. Now, let A be an algorithm that solves P. For each of the following statements about A below [(1)-(4)] determine whether or not the statement is consistent with the information provided about the worst-case asymptotic time complexity of P. For example, for (1), determine whether or not it is possible for A to have worst-case time complexity in ( n2 lglgn) given that P’s worst-case time complexity is in O(n3 lg(nlgn)2) and is also in ( n2 lg(n3lgn)). Note that when working on (1) you can ignore statements [(2)-(4)]. 1) A has worst-case time complexity in (n2 lglgn). 2) A has worst-case time complexity in (n2 lg( n3/lgn )). 3) A has worst-case time complexity in( n3 lglgn ). 4) A has worst-case time complexity in O( n2 2lgn ). 2. (10 points) Function Order of Growth: Given the following 4 functions: 3n lg n n 8lg n3 lglg 2 4lg2n 5 lg n! List the 4 functions in order of nondecreasing asymptotic size. Justify your answer. 3. (10 points) Recurrence: Find tight upper and lower asymptotic bounds on the solution to the following recurrence: 2 n T (n) 81T 9 2 log3 n 3 You may assume that T(3) = 1 and n is a power of 3. page 1 of 2 Explain your answer. UML CS Analysis of Algorithms 91.503 (section 201) Fall, 2004 4. (10 points) Dynamic Programming: Determine an LCS of these two strings: <A, B, B, A, B, A, B, A> and <B, A, B, B, A, B, B, B, A>. 5. (60 points) Dynamic Programming: A particle moves leftwards in a straight line along the x axis towards the origin x = 0. It starts at initial position x0 at time t = 0. The particle moves leftwards with initial velocity v1, where moving leftwards results in positive velocity. Its velocity remains constant until the particle reaches position x1 at time t = 1, at which time its positive velocity becomes v2. From there its velocity again remains constant until the particle reaches position x2 at time t = 2, at which time its positive velocity becomes v3. From there its velocity again remains constant until the particle reaches its final resting position at the origin x3 = 0 at time t = 3. Solve the following problem using dynamic programming: express x1, x2, x3 and v1, v2, v3 in terms of x0 under the condition that v12 + v22 + v32 is minimized. a. Characterize the structure of the optimal solution. b. Recursively define the value of an optimal solution. c. Compute the value of an optimal solution in a bottom-up fashion. d. Construct an optimal solution from the computed information. page 2 of 2