I am having difficulty trying to find the total number of operations in the following code block:
for(int i = 1; i <= n; i *= 2) {
for(int j = 1; j <= i; j *= 2) {
// What is the number of operations here, with respect to n?
}
}
My thinking was that: there are floor(log_2(n)) operations in the outer loop, and log_2(i) operations in the inner loop. I am not sure if my thinking is right, and how I would go from here... How could this be written in terms of solely n?