in Algorithms edited by
254 views
0 votes
0 votes
what is the time complexity for this code
 

for(i=1; i<=n ; i++){

      for(j=1; j<=log(i) ; j++){

          //Do something

           }

}
in Algorithms edited by
254 views

3 Comments

i=1 ===> j loop runs log (1) times

i=2 ===> j loop runs log (2) times

i=3 ===> j loop runs log (3) times

......

i=n ===> j loop runs log (n) times

Total time runs = log(1) + log(2) + ....+ log(n) = log (1.2.3.4.....n) = log (n!) = log(nn) = n.log(n)

1
1
O(nlogn) ?
1
1
Thank you for the explanation!
0
0

Please log in or register to answer this question.

Related questions

2 votes
2 votes
1 answer
4