Counting steps

An algorithm's cost is the number of basic steps it takes as a function of the input size $n$, so one pass over $n$ items takes about $n$ steps and comparing every pair, a loop inside a loop, about $\frac{n^2}{2}$, and doubling $n$ doubles the first and quadruples the second.

From Data Structures and Algorithms.