Tabulate at coarse sample points and interpolate between them. For a sine, instead of a table entry per possible float input (impossible), store, say, 256 samples across one period; for an input that falls between two samples, linearly interpolate the two nearest entries (a + frac*(b-a)). This keeps the table small and the lookup O(1) (compute the index, read two neighbors, interpolate), at the cost of a small interpolation error. The resolution becomes a dial: more samples reduce error but cost memory; fewer samples save memory but increase error, you pick the smallest table that meets your accuracy budget. Higher-order interpolation (cubic) reduces error further at more compute. This is how DDS sine generators, gamma curves, and sensor-linearization tables cover continuous domains with bounded memory.
Data Structures & Algorithms · Interview question
The domain is too large to tabulate every input. What do you do?
A strong answer
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
Lookup Tables & Precomputation
Trade memory for time: precompute expensive results into a table and replace an O(k) runtime computation with an O(1) array read, the space-time tradeoff that powers DSP, trig, and CRC.