Exponents, logs & growth

intro 13 mincs-bridge-basics

Builds on:Functions are machines

The idea

Exponentials grow by repeated multiplication; logarithms ask how many multiplications it took to reach a given number. In computer science, logarithms show up whenever a problem is repeatedly halved, and exponentials show up in brute-force search spaces — comparing growth rates like these is central to algorithm analysis.

Real-world: finding a name in a sorted directory

Binary search checks the middle entry and discards half of the remaining names at each step, so a directory of 1,024 names shrinks to 512, then 256, then 128, and so on. Reducing 1,024 possibilities down to one takes 10 halvings, because 1024=2101024 = 2^{10} — this is why binary search runs in about log⁡2(n)\log_2(n) steps.

log nnn²2ⁿ

At n=3, exponential growth begins to leave polynomial growth behind.

Worked example

  1. Binary search halves the remaining range each step
  2. 1024=2101024 = 2^{10}
  3. Ten halvings reduce 1,024 candidates to one; an ordinary successful search may perform an additional final comparison
  4. So the search takes about log⁡2(n)\log_2(n) steps—up to 11 comparisons for 1,024 items, depending on the convention and implementation

Cheat sheet

2x=n  ⟺  log⁡2(n)=x2^x = n \iff \log_2(n) = x