Example: Measuring Time Complexity of a Single Loop Algorithm

In this lesson, we are going to learn how to compute the time complexity of an algorithm that involves a for loop.

A For Loop With n Iterations

Now, let’s consider what happens when a loop is involved. Consider the following javascript program:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.