0 votes 0 votes What will be the time-complexity of the following ? for(i=1;i<=n;i=i*2) { for(j=0;j<i;j++) { count++; } } Algorithms time-complexity + – Phlegmatic asked Jun 21, 2018 • edited Jun 21, 2018 by srestha Phlegmatic 416 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply srestha commented Jun 21, 2018 reply Follow Share Answer $O(n)$ ?? 1 votes 1 votes Phlegmatic commented Jun 21, 2018 reply Follow Share I got that too. Can you please show me the steps or tell me how you figured out. n+n/2+n/4 +n/8 +..................... is the series coming ? 1 votes 1 votes srestha commented Jun 21, 2018 reply Follow Share yes 0 votes 0 votes Phlegmatic commented Jun 21, 2018 reply Follow Share Thanks Mam 1 votes 1 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes 1+2+4+8+....+n (GP, logn+1 terms) =2n-1 = O(n) Verma Ashish answered Jun 21, 2018 • selected Jun 21, 2018 by Phlegmatic Verma Ashish comment Share Follow See 1 comment See all 1 1 comment reply Phlegmatic commented Jun 21, 2018 reply Follow Share Thanks 0 votes 0 votes Please log in or register to add a comment.