0% found this document useful (0 votes)
185 views

(CSE303: ADA) (Assignment-1) : Count 0 For (I 1 I N I For (J 1 J N J Count Count +1

This document contains 7 questions regarding the analysis of asymptotic complexity of algorithms using Big-O, Ω, and Θ notation as well as recursion trees and the master method. The questions cover proving or disproving conjectures about time complexity functions, ranking time complexities by order of growth, analyzing the time complexity of recursive and non-recursive algorithms, determining which of two functions is asymptotically larger, drawing a recursion tree and determining tight bounds, and using the master method to solve recurrences.

Uploaded by

Akshat Bhatnagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views

(CSE303: ADA) (Assignment-1) : Count 0 For (I 1 I N I For (J 1 J N J Count Count +1

This document contains 7 questions regarding the analysis of asymptotic complexity of algorithms using Big-O, Ω, and Θ notation as well as recursion trees and the master method. The questions cover proving or disproving conjectures about time complexity functions, ranking time complexities by order of growth, analyzing the time complexity of recursive and non-recursive algorithms, determining which of two functions is asymptotically larger, drawing a recursion tree and determining tight bounds, and using the master method to solve recurrences.

Uploaded by

Akshat Bhatnagar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

[CSE303: ADA] [Assignment-1]

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.

a. f ( n )=O ( g ( n ) ) implies g ( n )=O( f (n)).


b. f (n)+ g(n)=Θ( max( f (n) , g( n))).
c. f (n)=O(g(n)) implies lg ⁡¿
where lg (g(n))> 0∧f (n) ≥1 for all sufficiently large n .
d. f ( n )=O ( g ( n ) ) implies 2f (n )=O(2 g (n) )
e. f (n)=O(g(n)) implies g (n)=g( n)=Ω(f (n)) .
f. f (n)=Θ( f (n /2)).
g. (n+ a)b=Θ(n b) where a and b are constants.

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.4: Find which function is greater (asymptotically larger)

1. f ( n )=n2 logn g ( n )=n(logn)10


2. f ( n )=3 n√ n g ( n )=2√n logn
3. f ( n )=nlogn g ( n ) =2√ n
4. f ( n )=2logn g ( n )=n √ n
5. f ( n )=2n g ( n )=22 n
Q.5 Draw the recursion tree for T ( n)=4 T ( ⌊ n/2 ⌋ +n and provide tight asymptotic bound
on
its solution.

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

(iii) T ( n )=4 T ( n2 )+ n logn


2

***************************************************

You might also like