GATE Computer ScienceEasyGATE CS (PYQ pattern)

A loop executes `for (i = 0; i < n; i++) sum += a[i];` with a large array a. Which memory access pattern shows strong spatial locality but essentially no temporal locality?

  1. A. Repeated fetches of the loop's instructions
  2. B. Repeated use of the variable i
  3. C. Successive reads of a[i]
  4. D. Repeated updates of sum

Correct answer: C. Successive reads of a[i]

Each element is used once, but neighbouring elements share cache blocks (spatial). sum, i and the loop body are reused every iteration (temporal).

More Computer Organization and Architecture questions

Exams that ask this topic