Reputation: 11
int p=0;
for(int i=0;i<n;i=i*2)
{
p++;
}
for(int j=0;j<p;j=j*2)
{
//statements
}
I am getting the time function to be log(N) + log(log(N)). My main question is whether the Time Complexity in this case would be O(logN) or O(log(logN)).
Upvotes: 1
Views: 38
Reputation: 311103
O(log(log(N)) is negligible compared to O(log(N)), so you can say the overall time complexity is O(log(N)).
Upvotes: 3