0 0 votes What will be time complexity for the following algo where n is a Prime number? main() { for(i=1; i<=n; i=2*i) for(j=1; j<=n; j++) { if(n%i == 0) while(k<=n) { a=b+c k=k+1 } } } Algorithms time-complexity + – parulk 715 views answer comment Share Follow Print See 1 comment 1 1 comment reply sourav. commented Jun 3, 2017 reply Follow flag please correct the question !what is k? what is its initial value ? 1 1 replyShare Please log in or register to add a comment.
0 0 votes outer loop runs floor(logn +1) = log n and inner loop worst case n^2 so worst case total time complexity of program=(n^2)logn,plz correct me if wrong aik138463 answered Jun 3, 2017 aik138463 comment Share Follow See 1 comment 1 1 comment reply parulk commented Jun 3, 2017 reply Follow flag ok i got it! yes it is the correct answer 1 1 replyShare Please log in or register to add a comment.