AI Features

Non Trivial Runtime

In this lesson, we'll discuss an example with a non-trivial runtime.

We'll cover the following...

Sum of powers

Take the code sample below:

for (int i = 1; i <= N; i *= 2)
    for (int j = 1; j <= i; j++)
        x++;

As discussed earlier, the outer loop runs (logN+1)(logN + 1) ...