Skip to content

time complexity

Time complexity measures how the running time of an algorithm grows as the size of its input increases. It counts the number of elementary operations an algorithm performs rather than wall-clock seconds, so the measure stays meaningful across different machines and languages.

Time complexity is usually expressed in Big O notation, which gives an upper bound on the growth rate. An algorithm that runs in O(n) time does work proportional to the input size n, while one that runs in O(n^2) time takes four times as long whenever the input doubles.

Analysts often separate the worst case, the average case, and the best case, because one algorithm can behave very differently depending on its input. Different growth rates explain large practical gaps. Binary search runs in O(log n) time and stays fast on huge inputs, while a plain scan runs in O(n) time.

Time complexity is the main lens for comparing algorithms, alongside space complexity, which tracks memory use instead.

Tutorial

Sorting Algorithms in Python

In this tutorial, you'll learn all about five different sorting algorithms in Python from both a theoretical and a practical standpoint. You'll also learn several related and important concepts, including Big O notation and recursion.

intermediate algorithms python

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated June 22, 2026 • Reviewed by Leodanis Pozo Ramos