Upgrade to Pro — share decks privately, control downloads, hide ads and more …

homework1.pdf

Avatar for koshizu koshizu
April 15, 2012
63

 homework1.pdf

Avatar for koshizu

koshizu

April 15, 2012

Transcript

  1. Algorithms Homework #1 Due Oct, 11, 2011 before class. Collaboration

    policy: You can discuss the problem with other students, but you must obtain and write the final solution by yourself. Please specify all of your collaborators (name, student id) for each question. Problem 1 (20%) 1. Is it true that if f(n) = O(g(n)), f(n) ≥ 2 and g(n) ≥ 2, then log f(n) = O(log g(n))? Justify your answer. 2. Is it true that if f(n) = O(g(n)), then 2f(n) = O(2g(n))? Justify your answer. In the above two questions, you are only allowed to use the definitions of asymptotic notations. Problem 2 (20%) Solve the following recurrences. The answers need to be exact. You may not use any asymptotic notations. (For example: You can answer T(n) = 3n2 − 2n but not T(n) = Θ(n2).) 1. T(n) = 4T(n 2 ) + 2n2, T(1) = 0. (You only need to solve T(n) for n = 2k where k is a positive integer.) 2. T(n) = 4T(n − 1) − 3T(n − 2) + 6 for all n ≥ 3. T(1) = 2. T(2) = 5. Problem 3 (30%) Let T(1) = 1. Derive the asymptotic solution (in Θ()) of the following recurrence relations: 1. T(n) = 2T(n 2 ) + n log2 n . 2. T(n) = n4 4 T(n 2 ) + n2. 3. T(n) = 2n[T(n 2 )]4. 1
  2. Problem 4 (20%) Let f(n) and g(n) be positive functions

    satisfying f(n) = g(n) for all n ≤ 1 and f(n) = f(2n 3 ) + f(n 2 ) + g(n) for all n > 1. Prove or disprove the following statements: 1. If g(n) = Θ(n2), then f(n) = O(g(n)). 2. If g(n) = Ω(n2), then f(n) = O(g(n)). Problem 5 (20%) Let S(n) be the number of n bit binary strings that contain two consecutive 0s. For example, S(3) = 3 because there are three strings 000, 001 and 100 that contain two consecutive 0s. 1. Derive a recurrence relation for S(n). 2. Derive the asymptotic solution (in Θ()) of S(n). 2