0 votes 0 votes what is the time complexities of the following code snippets. 1. k=1;i=1; while(k<=n) { i++; k=k+i; } 2. for(i=1;i<=n;++i) { for(j=1;j<n;j=j*2) c=c+1; } 3. m=pow(2,n) for(i=1;i<=n;i++) { for(j=1;j<=m;j=j*2) c=c+1; } Algorithms algorithms + – Iamniks4 asked Jan 16, 2019 Iamniks4 347 views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Kunal Kadian commented Jan 16, 2019 reply Follow Share 1. $O(n) $bcoz k still grows linealry even though i added. 2. $O(nlogn) $ 3.$O(nlogm) = O(n^2)$ Correct? Can someone else verify? 0 votes 0 votes Verma Ashish commented Jan 16, 2019 reply Follow Share @Kunal Kadian i think for 1. it should be $O(\sqrt n)$ since for $i=p, k= \frac{p(p+1)}{2}$, and i (=p) represents no. of times looping is done. So $p=O(\sqrt n)$ 0 votes 0 votes garimanand commented Jan 17, 2019 reply Follow Share 1) O(sqrt(n)) 2) O(nlogn) 3) O(n^2) 1 votes 1 votes Please log in or register to add a comment.