midterm_review - 1. Order the following running time bounds...

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

View Full Document Right Arrow Icon
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++; } The sums on page #5 of the text may help. 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. Someone proposed that we stop the recursion once the size reaches
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.

This note was uploaded on 12/11/2010 for the course CSE CSE 2011 taught by Professor Neugyen during the Winter '09 term at York University.

Page1 / 2

midterm_review - 1. Order the following running time bounds...

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