Data Structures & Algorithms · Interview question

What's a CRC table and why is it faster than computing CRC directly?

A strong answer

A CRC (cyclic redundancy check) computed the textbook way processes the message one bit at a time, doing a shift and conditional XOR per bit, 8 operations per byte. A CRC lookup table precomputes, for all 256 possible byte values, the CRC contribution of that byte (the result of running those 8 bit-operations), so the per-byte step becomes a single table read combined with the running CRC via one XOR and a shift, processing a whole byte at once instead of bit-by-bit, roughly an 8× reduction in work. The table is 256 entries (512 bytes for CRC-16, 1 KB for CRC-32), placed in flash as a const array, typically generated offline from the CRC polynomial. This is why every high-throughput CRC implementation is table-driven: at line rate you can't afford 8 operations per bit, but you can afford one table lookup per byte. It's the canonical embedded example of precomputation converting an O(8·n) loop into an O(n) table-driven pass.

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.

More Lookup Tables & Precomputation questions

Browse all 472 interview questions
What's a CRC table and why is it faster than computing CRC directly? | EmbeddedPrep.io