Big O Notation
Big O is the shorthand for describing that growth. It deliberately ignores constants and small details, because at large n only the shape matters.
O(1) constant, indexing a list, checking a dictionary key
O(log n) logarithmic, binary search
O(n) linear, one loop through the data
O(n log n) the speed of good sorting algorithms
O(n²) quadratic, a loop inside a loop
O(2ⁿ) exponential, effectively unusable beyond tiny inputs
Reading it is simple: find the most expensive part of the code, and describe how it grows.
Two loops one after the other is still O(n), because you pass the data twice and 2n is still linear growth. Two loops nested inside each other is O(n²). Sequence adds, nesting multiplies.
Mark this lesson complete
Signed in, your progress follows you to every device.