Complexity
Big-O Comparison
Theoretical growth makes the difference between linear, n log n, and quadratic work easier to see than raw browser timing.
Chart
Growth by input size
n=8
64
n=16
256
n=32
1,024
n=64
4,096
n=128
16,384
n=256
65,536
Red: O(n^2)Blue: O(n log n)Green: O(n)
Numbers
Sample operation counts
| n | O(n) | O(n log n) | O(n^2) |
|---|---|---|---|
| 8 | 8 | 24 | 64 |
| 16 | 16 | 64 | 256 |
| 32 | 32 | 160 | 1,024 |
| 64 | 64 | 384 | 4,096 |
| 128 | 128 | 896 | 16,384 |
| 256 | 256 | 2,048 | 65,536 |