Question:medium

Consider the two-dimensional array D[128][128] in C, stored in row-major order. Each physical page frame holds 512 elements of D. There are 30 physical page frames. The following code executes:
for (int i = 0; i<128; i++)
    for (int j = 0; j<128; j++)
        D[j][i] *= 10;
The number of page faults generated during this execution is:

Show Hint

In C, arrays are row-major. Column-wise traversal causes poor locality, leading to excessive page faults. If the loops were swapped (row-wise), page faults would reduce drastically.
Updated On: Jan 31, 2026
Show Solution

Correct Answer: 4096

Solution and Explanation

Was this answer helpful?
0