{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSE 2011 MIDTERM REVIEW

# CSE 2011 MIDTERM REVIEW - NOTE As you may have noticed we...

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

NOTE: As you may have noticed, we use a lot of examples and diagrams in the lectures. So email is not an effective method to answer questions related to course material. Please DO NOT ask how to solve the following problems via email. Come to the office hours instead. 1. Order the following running time θ bounds by asymptotic growth rate in nondescending order. Indicate equality, if any. N 2 , 2 N , 25, Nlg(lgN), Nlg(N 2 ), N 2 lgN, N 3 , NlgN, and N! . 2. Solve the following recurrences by obtaining a θ bound for T(N) given that T(1) = θ(1) : a. T(N) = 2N - 1 + T(N-1) b. T(N) = N + T(N-3) c. T(N) = N 2 + T(N-1) 3. Perform a worst-case analysis of each of the following fragments and give a θ bound for the running time: a. sum = 0; for (int i = 0; i < N; i++) for (int j = 0; j < i * i; j++) for (int k = 0; k < j; k++) sum++; b. sum = 0; for (int i = 0; i < N; i++) for (int j = 0; j < i * i; j++) if (j % i == 0) { for (int k = 0; k < j; k++) sum++; } 4. Mergesort does have a worst-case time of θ(NlgN) but its overhead (hidden in the constant factors) is high and this is manifested near the bottom of the recursion tree where many merges are made.

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 ]}