0 votes 0 votes p=0; for(i=1;i<n;i=2*i) { p=p+i; } for(j=1;j<p;j<2*j) { statement; } what will be time complexity??? BASANT KUMAR asked Sep 19, 2018 • edited Sep 19, 2018 by BASANT KUMAR BASANT KUMAR 1.6k views answer comment Share Follow See all 15 Comments See all 15 15 Comments reply Show 12 previous comments arvin commented Sep 20, 2018 reply Follow Share See for case 1 : first loop will execute... Where p=p+i ... So as the loop ends the value of .will be n. As i have proved that.. . Now 2nd loop will run where j<p and j=2j.. so it will go for logp = logn. . @basant : check the second for loop it has j<2j instead of j=2j 1 votes 1 votes Mayankprakash commented Sep 20, 2018 reply Follow Share @arvin I got second case but in 1st case I'm not able to understand how --> 2(h+1)-1)/(2-1)= 2log2n -1 = nlog22 0 votes 0 votes BASANT KUMAR commented Sep 20, 2018 reply Follow Share Its my typing mistakes.sorry for that.in second loop it will be j= 2*j 0 votes 0 votes Please log in or register to add a comment.