You have read O(log n) a hundred times. Binary search is O(log n). A balanced BST lookup is O(log n). Heap insert is O(log n). We nod along — log n means "fast" — and move on.
But what is that logarithm actually counting? Once it clicks, a whole family of algorithms stops being trivia you memorized and becomes one idea you understand.
A logarithm counts halvings
Forget the textbook definition for a second. Here's the one that matters for algorithms:
log₂(n) is the number of times you can halve n before you reach 1.








