{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Fl03Hw2

# Fl03Hw2 - Home Work 2 Fall 2003 CSE 4081 5211 Due Points 50...

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

Home Work 2 Fall 2003 CSE 4081/ 5211 Due: 10/7/03 Points: 50 1) Prove that X^2 = O(2^X) For c=1, X^2 <= 2^X, for every X>=4. Hence for (c=1, N0=4) the definition of big-O follows. 2) Set up its recurrence equation and find the general solution. procedure no-use (set S) if (set size == 1) then // complexity O(1) do nothing; else for each subset S1 of S print S1; // Complexity O(2^n) no-use (S – next element s belonging to S) // T(n-1) end if end procedure Recurrence equation, T(n) = T(n-1) + 2^n + c Solving by telescoping: T(n) = T(n-1) + 2^n +c = T(n-2) + 2^(n-1)+2^n +c +c = … = T(1) + 2^n + 2^(n-1) + 2^(n-2) + … +2^2 + (n-1)c = O(2^n) 3) Generate a list of ten unique numbers between 1 and 999 (e.g., 50, 2, 895, 59, 400, 300, 25, 19, 600, 932). Input 8 1 4 9 0 3 5 2 7 6 a) Show the whole sorting procedure of Insertion sort. 8 1 4 9 0 3 5 2 7 6 1 8 4 9 0 3 5 2 7 6 1 4 8 9 0 3 5 2 7 6 1 4 8 9 0 3 5 2 7 6 0 1 4 8 9 3 5 2 7 6 0 1 3 4 8 9 5 2 7 6 0 1 3 4 5 8 9 2 7 6 0 1 2 3 4 5 8 9 7 6 0 1 2 3 4 5 7 8 9 6 0 1 2 3 4 5 6 7 8 9

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

View Full Document
b) Show the whole sorting procedure of Quick sort (rearrange the number carefully, so that the algorithm makes three or more recursive calls).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}