2008+CS+361+midterm

# 2008+CS+361+midterm - CS 361 Midterm Exam Tuesday Put your...

• Notes
• 6

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

CS 361 Midterm Exam. Tuesday, October 21, 2008 Put your name in the top-right corner of each page! Write your answers in the space provided. Be concise! There are 6 problems, each worth 20 points. 1. (20 points) For each of the following, determine whether f ( n ) is O ( g ( n )), Ω( g ( n )), Θ( g ( n )) or none of the above. Justify your answers. (a) f ( n ) = 10 6 n , g ( n ) = n 2 2 (b) f ( n ) = n log n , g ( n ) = (log n ) n (c) f ( n ) = 2 log n , g ( n ) = n 3 (d) f ( n ) = n 2 (log n ) 5 , g ( n ) = n 3 1

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

2. (20 points) Suppose f, g, h are functions such that f ( n ) = O ( h ( n )) and g ( n ) = O ( h ( n )). Answer the following questions. Prove your answers. (a) What is the best that can be said about the sum f + g ? (b) the product fg ? (c) the difference f - g ? (d) True or false: f g = O ( h h ). 2
3. (20 points) Consider the following algorithm. mystery(A): /* takes an array of integers as input */ Let n denote length(A) for i = 1 to n for j = i+1 to n if A[j] < A[i] swap A[i] and A[j] endif endfor endfor output A (a) What does this algorithm do? (b) Let T ( n ) denote the (worst-case) running time for this algorithm on an array of length n . Give a function f such that T ( n

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

This is the end of the preview. Sign up to access the rest of the document.
• Spring '10
• Gula
• Graph Theory, Big O notation, Analysis of algorithms, Partially ordered set, Yellowstone

{[ 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