Docsity

Algorithms and Data Structure - 11 Problems in Homework 2 | CS 561, Assignments of Computer Science

Toggle sidebar
bg1
CS 561, HW2
Prof. Jared Saia, University of New Mexico
Due: Sept. 27th
Please use no outside references in solving these problems.
1. Consider the recurrence T(n)=3T(n/4) + 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)
2. Consider the following function:
int f (int n){
if (n==0) return 3;
else if (n==1) return 5;
else{
int val = 3*f (n-1);
val = val - 2*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)
(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.
3. Exercise 6.1-4
4. Exercise 6.1-5
1
pf2

Partial preview of the text

Download Algorithms and Data Structure - 11 Problems in Homework 2 | CS 561 and more Assignments Computer Science in PDF only on Docsity!

CS 561, HW

Prof. Jared Saia, University of New Mexico

Due: Sept. 27th

Please use no outside references in solving these problems.

  1. Consider the recurrence T (n) = 3T (n/4) + 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 3; else if (n==1) return 5; else{ int val = 3f (n-1); val = val - 2f (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. Exercise 6.1-
  2. Exercise 6.1-
    1. Exercise 6.4-
    1. Exercise 6.5-
    1. Problem 6-
    1. Exercise 7.1-
    1. Problem 7-
    1. Problem 7-
    1. Problem 7-