Data Structures & Algorithms · Interview question

What is the space-time tradeoff, and give an embedded example.

A strong answer

It's the principle that you can often reduce time cost by spending more memory, or reduce memory by spending more time, they trade against each other. The classic embedded example is a lookup table: instead of computing a function at runtime (say a sine value, a CRC step, or a gamma correction), you precompute the results into a table at build time and replace an expensive O(k) computation with an O(1) array read, paying flash/RAM for the table to buy speed and determinism. Hashing is another: you allocate a sparse table (memory) to turn an O(n) search into an O(1)-average lookup. The reverse direction also happens, on a RAM-starved part you might recompute a value each time rather than cache it. The embedded skill is placing yourself on that curve deliberately given your flash, RAM, and WCET budget; there's no universally right point.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

Time & Space Complexity

Big-O describes how cost grows with input size, and on an MCU you also care about the constants it hides, worst-case determinism (WCET), and the space-time tradeoff.

More Time & Space Complexity questions

Browse all 472 interview questions