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

A homework assignment for cs 361: algorithms and complexity analysis, taught by prof. Jared saia at the university of new mexico. The assignment covers the analysis of recurrence relations using the recursion tree method, annihilators, and the master theorem. Students are required to find tight upper bounds for the solutions to given recurrences and write recurrence relations for given functions, as well as analyze their running times.

Typology: Assignments

Pre 2010

Uploaded on 07/23/2009

koofers-user-k62
koofers-user-k62 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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.