Complexity Analysis of Algorithms

Let's understand how the complexity of an algorithm is analyzed using worst, best and average-case scenarios.

Time complexity cases

The amount of time required to execute an algorithm is referred to as the time complexity. It is analyzed through the following three different kinds of scenarios:

Worst-case complexity

The worst-case complexity represents the maximum number of steps required to execute an algorithm. It gives us the upper bound of an algorithm. Usually, we use this complexity to judge algorithm performance.

Best-case complexity

The best-case complexity represents the minimum number of steps required to execute an algorithm. It gives us the lower bound of an algorithm.

Average-case complexity

The average-case complexity represents the average number of steps required to execute an algorithm. Usually, we take the average of the best and worst cases to estimate average-case complexity.

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