What is the estimated complexity of this program?

Правка en2, от LilyWhite, 2019-01-29 13:54:39
int n;
cin>>n;
if (n==0)//deal with it
for (double i=0;i<=1/(double)n;i+=1e-9)//do something

It seems that, this code runs faster when n becomes larger...

When n = 109, the code will be executed once. When n = 1, it runs 109 times.

So I estimated it as O(n - 1).

But, this means that this algorithm runs even faster than O(1).

How is it possible?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский LilyWhite 2019-01-29 13:54:39 0 (published)
en1 Английский LilyWhite 2019-01-29 13:54:00 437 Initial revision (saved to drafts)