0 votes 0 votes int unknown(int n) { int i, j,k=0; for(i=n/2;i<=n;i++) for(j=2;j<=n;j=j*2) k=k+n/2; return(k); } Algorithms algorithms time-complexity + – Devshree Dubey asked Jun 8, 2016 retagged Jun 26, 2022 by makhdoom ghaya Devshree Dubey 496 views answer comment Share Follow See 1 comment See all 1 1 comment reply Devshree Dubey commented Jun 8, 2016 reply Follow Share Time complexity of this code is to be found 0 votes 0 votes Please log in or register to add a comment.
Best answer 6 votes 6 votes Answer would be $O(nlogn)$. Because outer loop runs $(n/2)$ times. Inner loop runs $O(logn)$ times. Hence total time is $O(nlogn)$. rude answered Jun 8, 2016 selected Jun 10, 2016 by rude rude comment Share Follow See all 0 reply Please log in or register to add a comment.