Loading page…
A nightly monitoring job reads a million readings on a small machine, and your team lead asks which versions fit. The lesson separates auxiliary space from total space and counts the call stack as memory: one call on one fewer item needs n plus one frames, and a call on half the items needs about log n. Measured on one laptop, reversing in place used no extra bytes, a reversed copy used 8,000,000 and an in-place sort used about 4,000,000. The lesson also shows the peak rule, the sum of allocations as a mistake, and why a recursion can fail on stack depth before memory runs out.
Your monitoring system reads a million readings each night.