for(int i = 0; i<100; i++){}
O(1)
for (int i = 10*n; i>0 ; i-=n) {}
for(int i = 0; i<n; i++){}
O(n)
for(int i = n; i>1; i = i/2){}
O(log(n))
for(int i = 0; i<n; i = i*2){}
for (int i = 1; i<n; i = i+i+i){}
for(int i = 1 ; i<=n ; i = i+i){}
for(int i = 0; i<n; i++) for(int j = 0; j<n; j++){}
O(n^2)
for(int i = 0; i*i<n; i++){}
O(sqrt(n))
for (int j = 1; j <n; j+=j) for(int i = 0; i<n; i++){}
O(log(n^2))
for (int j = 1; j*j <n ; j+=j) {}
O(log(sqrt(n))
for ( int i=0; i*i<n;++i)
for (int j = 0; j < n; ++j) {}
O(sqrt(n)*n)
int m = 1;
for (int i = 0; i < n; i++)
m*=2;
for (int i = 0; i < m; i++) {}
O(2^n)
for (int j = 1; j < n*n; j+=j) {}
O(n*log(n))
//Ohne n*n wäre es log n , so wird n nochmal multipliziert
Last changed2 years ago