If I have the following algorithm
for (i = 1; i <= 4 * n; i = i * 4) {
for (k = 1; k < 1000; k = 2 * k) {
print(k);
}
print(i);
}
how can I calculate its complexity?
I only understand that for one iteration of for(i=1; i≤4n; i=i*4)
, the line with print(i)
is O(1), and for one iteration of for(k=1; k<1000; k=2*k)
, the line with print(k)
is O(1).
I'm not sure how to proceed.