Two policies, chosen by what the data means. Drop the new item: reject the write (return false) and leave existing data intact, correct for lossless streams like received commands or a protocol where losing a byte corrupts a frame; the producer or a higher layer must handle backpressure (e.g. flow control). Overwrite the oldest: advance tail as well so the new item replaces the stalest one, correct for "latest value wins" data like a continuous sensor stream, where an old sample is worthless and you'd rather keep the freshest. The wrong default silently either discards fresh data you needed or destroys ordering you relied on, so it's a deliberate design decision per buffer. A third option is to apply backpressure upstream (pause the producer), but on an ISR-driven source you often can't, which forces the drop-vs-overwrite choice.
Data Structures & Algorithms · Interview question
The buffer is full and a new item arrives. What are your options?
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
Ring Buffers
The fixed-memory FIFO behind every UART driver: head and tail indices wrapping a static array, O(1) push/pop, and the full-vs-empty trick, plus the lock-free single-producer/consumer pattern.