AI Features

Logarithmic Runtime

In this lesson, we'll discuss when an algorithm can have a logarithmic runtime.

We'll cover the following...

Iterating powers of a number

Let’s analyze the loop below where we iterate over all powers of 22

for (int i = 1; i <= N; i *= 2)
    x++;
  • Iteration 11: i=1i=1
  • Iteration 22: i=2i=2
...