Professional Documents
Culture Documents
Q1: Let f(n) and g(n) be asymptotically positive functions. Using the basic definition of O,
Ω, and , Prove or disprove each of the following conjectures.
Q.2: Rank the following functions by order of growth; that is, find an arrangement
g1,g2,g3,g4,g5,g6mof the function satisfying g1=O(g2), g2=O(g3)…g5= O(g6)
n!, en, 4logn, (√2)logn, (2)√(2logn), n(1/logn)
Q.3: Analyse the time complexity of the following Non-recursive and Recursive algorithm
(code).
count=0; for (i=1 ;i≤n ;i++) fun(){∫ i=1 ; s=1;
for (i=1 ;i≤n ;i∗¿2) for ( j=1; j≤n ; j ++) while(s≤n)
for ( j=1; j≤n ; j∗¿2) j= j∗2 ; {
i++;
count=count +1; s=s+ i;
printf (Amity University) ;}
}
A()
{
∫ (∫ n )! void Test (∫ n )
int i,j,k,n { {
for(i=1; i<=n;i++) if ( n=¿ 0 ) if ( n>1 )
{ return 1 ; {
for(j=1; j<=i2;j++) else for ¿
{ return n∗(n−1)!; {
for(k=1;k<=n/2;k++)
}
{
printf("Amity");
printf ( Amity University ) ;
} }
} } } Test (n/2);
Test ( n/2);-
}}
Q.6 Find the upper bound of the following recurrence using recursion tree method
n n n
T ( n )=T
2() () ()
+T
4
+T
8
+n
Q.7 Use a Recursion tree (for Q.6(i)) and Master method (for Q.6(ii) and (iii)) to give an
asymptotic tight solution to the recurrence
n
(i)T ( n )=2 T ()
2
+ n2
(ii)
T ( n)=4 T ( n2 )+n √n
2
***************************************************