Example 1: 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.
We'll cover the following
In the previous lesson, we calculated the time complexity of the algorithm implemented in a simple C++ program.
A For Loop With n
Iterations #
Now, let’s consider what happens when a loop is involved. Consider the following C++ program::
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.