# Time complexity

66 views
what is the time complexity for this code

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

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

//Do something

}

}
1

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
O(nlogn) ?
0
Thank you for the explanation!

## Related questions

1
131 views
Finding the running time of the following algorithm. $Procedure$ $A(n)$ $\textrm{ if (n}<=\textrm{2) then return 1 ;}$ $else$ $Return(A(\left \lceil \sqrt{n} \right \rceil))$
Consider a procedure $find()$ which take array of $n$ ... Here we need to sort first and then need to compare adjacent element right?? Then what will be complexity??
Consider the following program: int Bar(int n){ if(n<2) return; } else{ int sum=0; int i,j; for(i=1;i<=4;i++) Bar(n/2); for(i=1;i<=n;i++){ for(j=1;j<=i;j++){ sum=sum+1; } } } Now consider the following statement $S_{1}:$ The time complexity of ... $S_{3}:$The time complexity of $Bar\left ( n \right )$ is $O \left ( n^{3}logn^{2} \right )$ How many statements are correct________________