434 views

1 Answer

Best answer
2 votes
2 votes

First consider how many times the inner loop runs.This can be found as :

       22^k   =  n   [As j begins from 2 and ends at n in inner loop and each time j = j2]

==>  2k    =  log2n

==>  k      = log(logn)

So inner loop runs log(logn) times..

And i runs n times independent of j..And for each i , j runs log(logn) times..

Hence overall complexity  =  O(nloglogn)

Hence 3) is the correct answer..

selected by

Related questions

3 votes
3 votes
1 answer
1
PEKKA asked Jan 2, 2017
575 views
f(n) = $\Theta (n^{2})$ g(n) = $\Omega (n)$ h(n)=O(log n) then [ f(n) . g(n) ] + [h(n) . f(n) ] is $\Omega (n)$$\Theta (n^{2})$O(log n)None
0 votes
0 votes
2 answers
2
PEKKA asked Dec 6, 2016
460 views
Complexity of the following snippet is for (i=1;i<n;++i) for(j=1;j<=n;j=j+i) c=c+1;
0 votes
0 votes
1 answer
4
PEKKA asked Dec 5, 2016
338 views
L={ambnckdl | (n-k ) is odd only if (m-l) is odd , m,n,k,l >=0 } is best fit under which language classRLDCFLCFLCSL