I know, the inner loop here is O(log n). But, I get confused by the multiplication in the outer loop part.
for (int i = 1; i <= 5*N; i++) {
for (int j = 1; j <= 1000; j = 2*j) {
doSomething(i, j);
}
}
The correct answer to the question is, O(N) with regard to: how many times does the function doSomething() run? But, I want to know, how this is calculated.
T(n) = O(log n), according to: https://www.quora.com/Can-anyone-tell-the-time-complexity-of-for-i-1-to-n-i-i*2-and-how