Description
1)
For each of the following statements, specify whether it is true or not. Explain your
reasoning for each of them.
a) log2 π
2 + 1 β Ξ(π)
b) βπ(π + 1) π Ξ©(π)
c) π
πβ1
π π(π
π)
d) π(2
π + π
3
) β π(4
π
)
e) πΆ(2 log3 βπ
3
) β π(3 log2 π
2
)
f) log2 βπ and (log2 π)
2
are of the same asymptotical order.
2) Order the following functions by growth rate and explain your reasoning for each of them.
π
2
, π
3
, π
2
log π, βπ, log π, 10π
, 2
π
, 8
logπ
3) What is the time complexity of the following programs? Explain by giving details.
a)
void f( int my_array[]){
for(int i=0;i<sizeofArray;i++){
if(my_array[i]<first_element){
second_element=first_element;
first_element=my_array[i];
}
else if(my_array[i]<second_element){
if(my_array[i]!= first_element){
second_element= my_array[i];
}
}
}
}
b)
void f(int n){
int count=0;
for(int i=2;i<=n;i++){
if(i%2==0){
count++;
}
else{
i=(i-1)i;
}
}
}
4 ) Find the complexity classes of the following functions using the integration method.
a) β π
2
log π
π
π=1
b) β i
n 3
i=1
c) β 1/(2βπ)
n
i=1
d) β 1/π
n
i=1
5) Find the best case and worst case complexities of linear search with repeated elements,
that is, the elements in the list need not be distinct. Show your analysis.

