0 votes 0 votes Algorithms algorithms time-complexity gateforum-test-series + – Gupta731 asked Jan 2, 2019 retagged Jul 7, 2022 by Lakshman Bhaiya Gupta731 510 views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply Abhisek Tiwari 4 commented Jan 2, 2019 reply Follow Share C? 0 votes 0 votes Gupta731 commented Jan 2, 2019 reply Follow Share Yes $C$ is correct. Please explain I tried taking an input and calculating the return value but got $A$ 0 votes 0 votes Abhisek Tiwari 4 commented Jan 2, 2019 reply Follow Share for i=1 to 10k //i++ for j=n to 1// n=n/2 p++ for i=1 first full iteration for j increment p logn times// n ,n/2,n/4 ....1 so 10k * logn so logn 0 votes 0 votes Gupta731 commented Jan 2, 2019 reply Follow Share n,n/2,n/4.... Isn't this nlogn 0 votes 0 votes Abhisek Tiwari 4 commented Jan 2, 2019 reply Follow Share why are u adding n n/2,n/4,n/8 ,,,,,,,, how many iteration it take to reach from n to 1 i.e logn its like for(i=1;i<n;i=i*2) TC==?? logn 0 votes 0 votes Gupta731 commented Jan 2, 2019 reply Follow Share yes got it, thanks bro 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes j>>=1 means rightshift 1 n/2^j =1 n=2^j j=logn gorya506 answered Aug 18, 2019 gorya506 comment Share Follow See all 0 reply Please log in or register to add a comment.