[Solved] How to calculate time complexity for this algorithm


Ask yourself, in which way does i increment grow towards the final value n? How many times will the outer loop run for a given n?

The same for the inner loop. I recommend you read through somthing like this or this SO post and maybe start with some examples:

n = 100;
i = 1;
while (i < n+1){
    j = 1;
    while (j < n+1) {
        j = j*2
    }
    i = i+1;
}

How many times exactly will both of the loops run?

1

solved How to calculate time complexity for this algorithm