Space Complexity & Hierarchy Theorems

log space

How little memory can a machine get away with and still do something interesting? Strikingly little: just enough to remember a handful of positions in the input. That is the regime of logarithmic space. Think of reading a thick book while keeping track of your place with a single bookmark and a small page-number written in the margin: you never copy the book down, you just remember where you are. Log space is exactly that discipline of holding a few pointers, not the data itself.

Why log n? To name one position among n input symbols, you need an index between 0 and n minus 1, and writing that index in binary takes about log2(n) bits. So O(log n) work cells is precisely enough to store a constant number of such pointers and counters, each able to range over the whole input. A log-space machine therefore cannot store the input (that would need n cells) nor any large structure; it works by repeatedly re-scanning the read-only input tape, advancing and comparing pointers. The read-only-input and work-tape convention is what makes this budget meaningful at all.

Log space is the home of the classes L and NL, and it is the smallest standard amount of memory we routinely study. It matters because surprisingly many natural tasks fit inside it (arithmetic comparisons, simple counting, checking graph paths nondeterministically) and because log-space reductions are gentle enough to compare problems without smuggling in extra power. A useful sanity check: a machine using O(log n) space can run for at most polynomially many steps before it must repeat a configuration and loop, so log space sits comfortably inside polynomial time.

A log-space machine can decide whether the input, read as a binary number, is divisible by 3: scan the bits left to right, keeping just the running remainder mod 3 (one of 0, 1, 2). That state plus a position pointer is a constant number of values, fitting in O(log n) work cells.

Log space holds a constant number of pointers and counters into the input, never the input itself.

A machine in O(log n) space has only polynomially many distinct configurations, so if it never repeats one it must halt within polynomial time. This is why L and NL both sit inside P.

Also called
logarithmic spaceO(log n) spacelogspace對數量級空間