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

Let’s consider what happens when a loop is involved. Consider the following C++ program::

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