wraparound
Moving an index past the last slot of an array back to slot zero, usually computed as (index + 1) % capacity.
In more detail
Wraparound is what turns a straight array into a ring buffer. Linear probing also wraps around to the start of the table when it reaches the end.
Example
new_index = (old_index + 1) % capacityRelated terms
- ring buffer — A fixed-size array used as a loop: when writes reach the end they wrap to the start, overwriting the oldest data.
- modulo — The operation that gives the remainder after division, written % in many programming languages, so 17 % 5 is 2.
- linear probing — An open-addressing rule: if a key's slot is taken, try the next slot, then the next, wrapping around, until a free one is found.
Taught in
- Deques And Ring Buffers — Algorithms & Data Structures for Working Engineers