Hi have some question regarding spatial and temporal locality. I have read in the course theory that
spatial locality
If one item is referenced, the likelihood of other address close by will be referenced soon
temporal locality
One item that is referenced at one point in time it tend to be referenced soon again.
Ok, but how do I see that in the code? I think I understood the concept for temporal locality but I don't understand spatial locality yet. For instance in this loop
for(i = 0; i < 20; i++)
for(j = 0; j < 10; j++)
a[i] = a[i]*j;
The inner loop will call same memory address when accessing a[i] ten times so that's an example for temporal locality I guess. But is there spatial locality also in the above loop?