22C:44 Algorithms
Due Tuesday, March 12, 2002
NOTE: Make sure you include short explanations with each of your answers below.
|
|
Give tight upper (O) and lower(W) bounds for T(n) in each of the following cases.
HINT: It might be helpful to elminate the f's and g's from T(n).
That is, rewrite T(n) in terms of n only. For example, if we have
T(n) = f(n) + g(n) then we can rewrite T(n) as
|
for (i = 5; i< n*n; i++) {
j = 1;
while (j < n) {
print(i*j + i*i - 3);
A[i,j] = j-i;
j = j + 2;
}
}
for (i = 1; i < n/2; i++)
B[i] = i*i*i;
i = 1;
while (i < n) {
for (j = 1; j < n; j++)
for (k = 1; k < n; k++)
A[j,k] := i * j;
i = i * 2;
}
for (i = 1; i < n; i++)
for (j = 1; j < n; j++)
A[i] += A[j + i] * i + j;
|