Algorithms

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 ___.

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.