CS502 Fundamentals of Algorithms Assignment 1 Solution Fall 2014

Question 1 (10)
Find the running time complexity of the following piece of code and show  your working step by step.
yz =0;
xw=0;
for(i=m; i>-6; i=i-6)
{ xw++; }
for (i=n; i>-2015;i=i-5)
{ yz=yz+1;}
for (i=1;i<=n;i=i*5)
{ for (j=1;j<=5n;j*12
{
for(k=n;k>-5; k=k-4)
{
x=x+12
}
}
}
Print x;
While(k<=z)
{
k=k*2
(
for(m=k; m>=-100000; m=m-1
)
}
Print k;

Question 2 (10)
Arrange the following in the Most to Least complexity order. Here “n “is  processing steps for some complexity functions and j< k and j & k are  numbers greater than 2. Every function is separated by “comma”.
Note: These functions must be arranged on generic basis. Further there are  20 functions to arrange and each line has five functions.
2 3 2
2 12 2 2 5  4 2 2 3
5 8 9
7 8 )
/1000 n-1000 og j/2 n/1000000, n , n , 1000 og n , n ,
log n 1000n 1
1000000000000, , 2 , og ( , 100000n!,
10000 1000
(n! og n), / ,n! og n / ,10000 og ( og ),1000n / ,
1
( og n) , n , ( og n)
2150

DOWNLOAD SOLUTION HERE
loading...