Computer Architecture — question 2 of 10
Write a real answer. It is graded against the question's rubric, and the mastery movement is computed by the same engine the product uses. Scoring here is deterministic rather than model-written, so this page costs nothing to run and nothing is saved. In a track built from your own posting, the same rubric is graded by the model, which is what produces feedback about your reasoning rather than about coverage.
Assume a standard cache with, say, 64-byte lines and no special prefetching beyond what a cache line fetch gives you for free.
You have a large 2D array of doubles stored in row-major order (each row contiguous in memory). One version of your code sums every element by looping over rows in the outer loop and columns in the inner loop. Another version swaps the loop order, iterating columns in the outer loop and rows in the inner loop. On a typical cache-based machine, the first version runs dramatically faster. Why?