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(N1)
b.
T(N) = N + T(N3)
c.
T(N) = N
2
+ T(N1)
3. Perform a worstcase 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 worstcase 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
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.
 Winter '09
 neugyen
 following questions, asymptotic growth rate, following running time, basic quicksort algorithm

Click to edit the document details