prob1 - CS38 Spring 2009 Introduction to Algorithms Prof...

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

CS38, Spring 2009 Introduction to Algorithms Prof. Alexei Kitaev Problem set #1 Due Friday April 10, 2009 at 5pm in the box in the VLSI lab. Problems 1. Exercises: a) (4 points) Sort the following functions in order of their asymptotic growth (i.e., the O -relation means “ ”, the Ω-relation means ‘ ”, and Θ means “=”: n, n log n, (log 2 n ) n , (ln n ) n , n ln n , 2 n , n ! , 2 n n , ln( n !) , ln 2 n n . You may use the Stirling approximation: n ! 2 πn ( n/e ) n . b) (3 points) Solve the recurrence T ( n ) = 3 T ( n/ 2) + O ( n 2 ). c) (3 points) Solve the recurrence T ( n ) = T ( n/ 3) + T (2 n/ 3) + O ( n ). 2. CLRS problem 2-2 (Correctness of bubblesort): a) (1 point) b) (4 points) c) (4 points) d) (1 point) 3. Let a sequence S = ( x 1 , . . . , x n ) be sorted. A corresponding sequence A = ( x f (1) , . . . , x f ( n ) ) is called “ k -almost sorted” if | f ( i ) i | ≤ k for all i = 1 , . . . , n . a) (10 points) Find an algorithm that sorts a k -almost sorted sequence in time O ( n log k ). You don’t need to reason using pseudocode; just give a higher-level correctness proof. Hint: Use merge-sort as a subroutine in your algorithm. b) (5 points) Prove the lower bound Ω( n log k ). Hint: Use the standard lower bound Ω( n log n

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

View Full Document
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