With respect to data accesses the line sum sum ai is only

With respect to data accesses the line sum = sum + a[i] is only an example of temporal locality. Why? Why it is not an example of spatial locality?

Solution

This is the example of temporal locality as the variable sum is again referenced in the future
and is referenced at the same location which itself defines the temporal locality.

Whereas Spatial locality can be defined as the memory location that is referred once.

Here the location of memory of variable sum is only referred to update the sum in loop each time.

With respect to data accesses the line sum = sum + a[i] is only an example of temporal locality. Why? Why it is not an example of spatial locality?SolutionThis

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site