Algorithms

Spatial locality

The idea that, if a program reads some data, it will probably soon read its neighbors. That's why the cache brings whole blocks, called lines. Temporal locality is the idea that used data gets used again soon.

Example

With 64-byte lines, reading one 4-byte integer from an array also brings the next 15.

Test yourself: Spatial locality

Memory and cache

You read element 0 of an integer array. What else does the cache bring?

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.