Skip to content

Big O notation

Big O notation tells you how quickly an algorithm’s running time or memory use grows as its input gets bigger. It describes an asymptotic upper bound on that growth rather than an exact step count, ignoring constant factors and lower-order terms, so you can compare how algorithms scale regardless of hardware or language.

A function written inside O(...) expresses an upper bound on growth. Common classes run from O(1) constant and O(log n) logarithmic, through O(n) linear and O(n log n) linearithmic, up to O(n^2) quadratic and O(2^n) exponential. The variable, n, is the size of the input, such as the number of elements in an array.

These classes line up from cheapest to most expensive as the input grows:

Interactive diagram — enable JavaScript to view.

The notation underlies both time complexity and space complexity analysis, and it appears throughout the study of algorithms.

Sorting Algorithms in Python

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 Sept. 17, 2026 • Reviewed by Leodanis Pozo Ramos