

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Computer Science 231 Spring 2009 Due: Tuesday, February 17 Reading. CLRS Chapter 3, pages 41 -- 61; Appendix A, pages 1058 --1069. CLR Chapters 2, 3, pages 20 -- 52 CLRS Exercise 2.3-3. Use mathematical induction to show that when n is an exact power of 2, the solution of the recurrence T ( n ) = 2 if n = 2, 2 T ( n / 2) + n if n = 2 k^ , k > 1
is T(n) = n lg n. Exercise 2.2. a. Suppose algorithm A has worst-case running time O( n ) and algorithm B has worst- case running time O( n^2 ). What can you say about the relative performance of the algorithms? b. Repeat part a for the worst-case running times Θ(n) and Θ( n^2 ). Exercise 2.3. Find two integer functions f(n) and g(n) such that f(n) is not O(g(n)) and g(n) is not O(f(n)). (An integer function is a function that maps integers to integers.) CLRS Problem 3-3a. You only need to hand in solutions to the 22 functions given below, not the 30 as given in the text. a. Rank the following function by order of growth; that is, find an arrangement g 1 , g 2 ,.. ., g 22 of the functions satisfying g 1 = Ω( g 2 ), g 2 = Ω( g 3 ),.. ., g 21 = Ω( g 22 ), Partition your list into equivalence classes such that f ( n ) and g ( n ) are in the same class if and only if f ( n ) = Θ( g ( n )). One way to do this is to list functions f ( n ) and g ( n ) on the same line if and only if f ( n ) = Θ( g ( n )). List all other functions on separate lines in order of their growth rates, fastest growth rates at the top of page. ( 2 ) lg n n^2 n! n^3 lg^2 n 22 n ln(ln n ) n ·2n^ ln n 1 2 lg^ n^ 4 lg^ n ( n +1)! ln n n 2 n^ n lg n 22 n + 1 n^2 n +1 (^) n 3 n
Assignment 2 Page 2 Computer Science 231 b. Give an example of a single nonnegative function f ( n ) such that for all functions gi ( n ) in part a, f ( n ) is neither O ( gi ( n )) nor Ω (gi ( n )). Hints. Here are a few relationships between notations that you may find useful.