• retagged by
715 views
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

              }

    }

}

1 Answer

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
Position:
Show:

Related questions

1 1 vote
1 1 answer
421
421 views
1 1 vote
1 1 answer
762
762 views
0 0 votes
1 1 answer
1.2k
1.2k views
amit166 asked Nov 24, 2018
1,201 views
T(n)=4T(n/2)+n$^{2}\sqrt{2}$ T.C
0 0 votes
0 0 answers
243
243 views
Ritabrata Dey asked May 4, 2019
243 views
Hello !! I am now facing a serious problem now-a-days ..cuz my sems will start within a month and lots of assignments and practicals are left to be written (copied) so i ...