Constant Complexity - O(1)

An algorithm has constant time complexity if it takes the same time regardless of the number of inputs. (Reading time: under 1 minute)

If an algorithm’s time complexity is constant, it means that it will always run in the same amount of time, no matter the input size. For example, if we want to get the first item of an array, it doesn’t matter how big the input size is.

It always takes the same amount of time to find the first element in the array. In a graph, it would look like this:

In the next lesson, I will talk about the linear time complexity of an algorithm.