Example: Measuring Time Complexity of a Single Loop Algorithm

In this lesson, you will 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 Java program::

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