O(log n) logarithmic space
easy 14 minO(log n) space almost always means a recursion whose call stack is logarithmically deep: each call halves the problem, so only about log₂ n frames are alive at once.
Where it shows up
The same pattern appears across everyday software.
Standard library sorts
C++'s std::sort uses introsort: quick sort that switches to heap sort once the recursion passes a depth of about 2 log₂ n. Its stack never grows beyond O(log n), even on adversarial input.
Recursion limits in real runtimes
Python stops at 1,000 frames by default and native threads often get a stack of a few megabytes. Logarithmic recursions such as binary search or balanced-tree code fit easily; linear recursions over large inputs crash with RecursionError or a stack overflow.
Sorted maps and their iterators
Java's TreeMap and C++'s std::map are red-black trees, so their height stays O(log n). A BST iterator keeps only the path to the current node, which is O(log n) memory for these balanced trees.
Database indexes
B-tree and B+ tree lookups descend one root-to-leaf path. With hundreds of keys per node a billion rows sit three or four levels deep, so a lookup holds only a handful of pages in memory at once.
Segment trees and range queries
Competitive programming and analytics code answer range-sum or range-min queries with a segment tree. A recursive query only goes as deep as the tree, about log₂ n levels, so its stack is O(log n).