13957586801914287955

Page 1

Introduction to Algorithm March 2014 1. (15%)Rank the following functions by order of growth. log n ln n, 2√2 log n, lg n, √2 , √n

2. (20%)Determin the tight bound for T (n) in each of the following recurrences. Assume that T (n) is constant for n ≤ 2 . a. T (n) = 2T (n/2) + n4 . b. T (n) = 7T (n/3) + n2 . c. T (n) = 2T (n/4) + √n . d. T (n) = T (n − 2) + n2 . 3. (15%)Suppose we have a staightforward algorithm for a problem that does θ(n2) steps for inputs of size n . Suppose we devise a divede­and­conquer algorithm that divides an input into two inputs half as big, and does n lg n steps to divide the problem and n lg n steps to combine the solutions to get a solution for the original input. Is the fivede­and­conquer algorithm more or less efficient than the straightforward algorithm? Justify your answer. 4. (15%)Assuming a penalty of 1 for a mismatch and a penalty of 2 for a gap, use the dynamic programming algorithm to find an optimal alignment of the following sequence. CAGGATGTCCAG GACTTCAGCAT 5. (20%)Let the graph G be defined as the following matrix. Use Dijkstra’s algorithm to find the shortest path from vertex 7 to vertex 3. Show your actions step by step. | 1 2 3 4 5 6 7 ­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 1 | 0 4 ∞ ∞ ∞ 10 ∞ 2 | 3 0 ∞ 18 ∞ ∞ ∞ 3 | ∞ 6 0 ∞ ∞ ∞ ∞ 4 | ∞ 5 15 0 2 19 5 5 | ∞ ∞ 12 1 0 ∞ ∞ 6 | ∞ ∞ ∞ ∞ ∞ 0 10 7 | ∞ ∞ ∞ 8 ∞ ∞ 0 6. (15%)Fill in a table by applying the fynamic programming algorithm for the knapsack problem on the following instance. Assum that the capcity W = 6 . item | 1 2 3 4 5 ­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ value | $25 $20 $15 $40 $50 weight | 3 2 1 4 5 ­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.