Nora Saad
Nora Saad

Reputation: 19

find big oh for "for loop that has method call"

I have tried to find the big oh for this code,

for(int i=0;i<n;i*=2)
fun(n);

where fun() is a method that has complexity of o(n^2)

and I figured that the for statement has complexity of o(log n). so, the big oh for all the code will be o(n^2logn). am i right ?

Upvotes: 0

Views: 73

Answers (1)

BarrySW19
BarrySW19

Reputation: 3809

It is O(Infinite), because you initialise i to 0 and then multiply it by two each iteration.

Upvotes: 7

Related Questions