Hacker News new | ask | show | jobs
by noctune 14 days ago
Locality is a property of how data is arranged, so it's a property of the data structure, no?
3 comments

It's a combination of both. Your data layout could be very cachable for one algorithm, but very much not so for another algorithm.
It has to be both. You can lay things out in memory so they are tightly packed together and thus ostensibly cache efficient but that doesn't help you if you index into that data structure in such a way that every new index loads a new cache line.
Data arrangement and data structure are the same word...
Kind of. Many dynamic set data structures do not require the set elements to be in some layout inside an array; the storage is abstracted.

When we put the binary tree nodes into an array and move from the parent to children using indexing calculations, rather following pointers that could go anywhere, then it's an explicit part of the data structure.