Circular array
An array used as if its ends were joined: when an index passes the last slot, it goes back to 0. It's computed with the remainder of a division.
Example
With length 5, the index after 4 is (4 + 1) % 5 = 0, just like on a clock 1 comes after 12.
Test yourself: Circular array
Queues
In a circular array of length 5, the index after 4 is ___.
(4 + 1) % 5 = 0: it wraps to the start. Index 5 doesn't exist in a 5-slot array, which goes from 0 to 4.
0/1
â–¶ Play