Math Fundamentals18 sections · 814 units
Open in Course

Logarithmic Growth vs Linear Growth (Scaling comparison)

Why log n is fast

Logarithmic growth is much slower than linear growth. If n=1000000n = 1000000, then log2(n)20\log_2(n) \approx 20. Linear search takes a million steps, binary search takes 2020.

Doubling nn from 10000001000000 to 20000002000000 increases linear time by 10000001000000, but only increases logarithmic time by 11 (from 2020 to 2121).

This is why O(logn)O(\log n) algorithms scale so well to huge inputs. Even with billions of elements, binary search takes fewer than 4040 steps.