Question: 1 . Find a tight upper bound for f ( n ) = n 4 + 1 0 n 2 + 5 . Write your

1. Find a tight upper bound for f ( n )=n 4+10 n2+5. Write your answer here: _______(4 points)
Prove your answer by giving values for the constants c and n 0. Choose the smallest integer value
possible for c.(4 points)
2. Find an asymptotically tight bound for f ( n )=3 n 32n. Write your answer here: _______(4 points)
Prove your answer by giving values for the constants c 1, c2, and n 0. Choose the tightest integer
values possible for c 1 and c2.(6 points)
3. Is 3 n4\epsi \Omega ( n2)? Circle your answer: yes / no.(2 points)
If yes, prove your answer by giving values for the constants c and n0. Choose the smallest integer
value possible for c. If no, derive a contradiction. (4 points)
4. Write the following asymptotic efficiency classes in increasing order of magnitude.
O(n2), O(2n ), O (1), O ( n lgn ), O(n), O ( n !), O(n3), O ( lg n ), O ( n n ), O ( n2 lgn )(2 points each)
_______,________,________,________,_______,_______,_______,_______,________,_______
5. Determine the largest size n of a problem that can be solved in time t, assuming that the algorithm
takes f(n) milliseconds. Write your answer for n as an integer. (2 points each)
a. f(n)= n, t =1 second __________
b. f(n)= n lg n, t =1 hour __________
c. f(n)= n2, t =1 hour __________
d. f(n)= n 3, t =1 day __________
e. f(n)= n !, t =1 minute __________
6. Suppose we are comparing two sorting algorithms and that for all inputs of size n the first algorithm
runs in 4 n 3 seconds, while the second algorithm runs in 64 n lg (n) seconds. For which integer
values of n does the first algorithm beat the second algorithm? _____________________(4 points)
CS 385, Homework 1b: Analysis of Algorithms
Explain in detail how you got your answer or paste code that solves the problem (2 point):
__________________________________________________________________________________
__________________________________________________________________________________
7. Give the complexity of the following methods. Choose the most appropriate notation from among \Omicron
,\Theta , and \Omega .(8 points each)
int function1(int n){
int count =0;
for (int i = n /2; i <= n; i++){
for (int j =1; j <= n; j *=2){
count++;
}
}
return count;
}
Answer: _________
int function2(int n){
int count =0;
for (int i =1; i * i * i <= n; i++){
count++;
}
return count;
}
Answer: _________
int function3(int n){
int count =0;
for (int i =1; i <= n; i++){
for (int j =1; j <= n; j++){
for (int k =1; k <= n; k++){
count++;
}
}
}
return count;
}
Answer: _________
int function4(int n){
int count =0;
for (int i =1; i <= n; i++){
for (int j =1; j <= n; j++){
count++;
break;
}
}
return count;
}
Answer: _________
CS 385, Homework 1b: Analysis of Algorithms
int function5(int n){
int count =0;
for (int i =1; i <= n; i++){
count++;
}
for (int j =1; j <= n; j++){
count++;
}
return count;
}
Answer:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!