hw2solutions

# Provide a counterexample to show that the following

• Notes
• 6

This preview shows pages 2–4. Sign up to view the full content.

Provide a counterexample to show that the following is false : For any(all) two functions f and g that map nonnegative reals to strictly positive reals we have that f ( n ) is O ( g ( n )) implies [ f ( n )] n is O ([ g ( n )] n ). Many other counterexamples were used in the solutions. A typical one was f ( n ) = 2 n and g ( n ) = n (for strictly positive n ; f (0) and g (0) can be whatever you want.). Now [ f ( n )] n = 2 n n n is [ g ( n )] n = n n . While it is true that 2 n n n is not O ( n n ) (so this is a good counterexample) this does not follow directly from what was proved or even just stated in the lecture notes. So those who gave this counterexample were also expected to prove that 2 n n n is not O ( n n ). Here is a proof. Suppose, toward a contradiction, that 2 n n n is O ( n n ). Then, N, c > 0 s.t. n N we have 2 n n n c n n . Therefore, n N we must have 2 n c and we have a contradiction witnessed by some n that is both bigger than N and strictly bigger than log c . Answer The counterexample is given by the functions f ( n ) = 3 and g ( n ) = 2. From the lecture notes we know that f ( n ) is O ( g ( n )). From the lecture notes we also know that 3 n is not O (2 n ). Problem 4: 20 points In this problem you are NOT allowed to use the theorems about Big-Oh stated in the lecture notes. Your proof should follow just from the definition of Big-Oh. Let a, b be two strictly positive constants let f, g be two functions that map nonnegative reals to strictly positive reals, and let C ( n ) = af ( n ) + bg ( n ) and D ( n ) = max( af ( n ) , bg ( n )). A. Prove that C ( n ) is O ( D ( n )). Answer Since n af ( n ) max( af ( n ) , bg ( n )) = D ( n ) and bg ( n ) max( af ( n ) , bg ( n )) = D ( n ), adding both sides of the inequalities we get that for all nonnegative n (so the functions are defined) we have C ( n ) 2 D ( n ). Therefore we have have shown that there exist c = 2 and N = 1 (to ensure that N > 0) such that n N C ( n ) c D ( n ). Note Some of the submitted solutions began with a separation into two cases: (1) a f ( n ) b g ( n ) and (2) a, f ( n ) b g ( n ) and then proceeded to show that C ( n ) is O ( a f ( n )) in case (1) and that C ( n ) is O ( b g ( n )) in case (2). Such a solution is not correct because while for fixed n we have that D ( n ) is either a f ( n )) or b g ( n )), there is no guarantee that we have the same 2

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

separation into cases for all n , and in proving C ( n ) is O ( D ( n )) we need to show an inequality for all n N . B. Prove that D ( n ) is O ( C ( n )). Answer Since a f ( n ) and b g ( n ) are both positive we have max( af ( n ) , bg ( n )) af ( n ) + bg ( n ) for all nonnegative n . Therefore we have have shown that there exist c = 21 and N = 1 (to ensure that N > 0) such that n N D ( n ) c C ( n ).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern