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

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

View Full Document Right Arrow Icon
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 ! , ± 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) 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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online