Docsity

CS 361 Homework 4: Recurrence Relations and Complexity Analysis, Assignments of Computer Science

Toggle sidebar
bg1
CS 361, HW4
Prof. Jared Saia, University of New Mexico
Due: February 17th, 2004
1. Consider the recurrence T(n) = 2T(n/4) + n2
(a) Use the recursion tree method to get a tight upper bound (i.e.
big-O) on the solution to this recurrence
(b) Now use annihilators (and a transformation) to get a tight upper
bound on the solution to this recurrence. Show your work. (Note
that your two bounds should match)
2. Consider the recurrence T(n) = 2T(n/2) + log2n
(a) Use the Master method to get a general solution to this recur-
rence.
(b) Now use annihilators (and a transformation) to get a tight upper
bound on the solution to this recurrence. Show your work. (Note
that your two bounds should match)
3. Consider the following function:
int f (int n){
if (n==0) return 0;
else if (n==1) return 1;
else{
int val = 6*f (n-1);
val = val - 9*f (n-2);
return val;
}
}
(a) Write a recurrence relation for the value returned by f. Solve the
recurrence exactly. (Don’t forget to check it)
1
pf2

Partial preview of the text

Download CS 361 Homework 4: Recurrence Relations and Complexity Analysis and more Assignments Computer Science in PDF only on Docsity!

CS 361, HW

Prof. Jared Saia, University of New Mexico

Due: February 17th, 2004

  1. Consider the recurrence T (n) = 2T (n/4) + n^2

(a) Use the recursion tree method to get a tight upper bound (i.e. big-O) on the solution to this recurrence (b) Now use annihilators (and a transformation) to get a tight upper bound on the solution to this recurrence. Show your work. (Note that your two bounds should match)

  1. Consider the recurrence T (n) = 2T (n/2) + log^2 n

(a) Use the Master method to get a general solution to this recur- rence. (b) Now use annihilators (and a transformation) to get a tight upper bound on the solution to this recurrence. Show your work. (Note that your two bounds should match)

  1. Consider the following function:

int f (int n){ if (n==0) return 0; else if (n==1) return 1; else{ int val = 6f (n-1); val = val - 9f (n-2); return val; } }

(a) Write a recurrence relation for the value returned by f. Solve the recurrence exactly. (Don’t forget to check it)

(b) Write a recurrence relation for the running time of f. Get a tight upperbound (i.e. big-O) on the solution to this recurrence.

  1. Consider the following function:

int f (int n){ if (n==0) return 0; else if (n==1) return 1; else{ int val = 4f (n-1); val = val - 4f (n-2); return val; } }

(a) Write a recurrence relation for the value returned by f. Solve the recurrence exactly. (Don’t forget to check it) (b) Write a recurrence relation for the running time of f. Get a tight upperbound (i.e. big-O) on the solution to this recurrence.