I am trying to study for an exam..and I found this example but can't understand how they got the answer. Can anyone explain it please?
Question:
Consider the two-dimensional array A: int A[][] = new int[100][100]; where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the matrix resides in the page 0 (location 0 to 199). Thus every instruction fetch will be from page 0. For two page frames, how many page faults are generated by the following array-initialization loops, using LRU replacement and assuming that the first page frame contains the process and the other is initially empty?
A:
for (int j=0;j<100;j++)
for (int i=0; i<100; i++)
A[i][j] = 0;
B:
for(int i=0; i<100; i++)
for (int j=0; j<100; j++)
A[i][j] = 0;
The correct answer given is : a: 100 x 50 = 5000 b: 50
I somewhat understand the first part. There are total of 50 pages. (10000/200=50) and every time j changes, a page fault occurs..so a total of 100 page faults..but why is that multiplied by 50? and why is the second one 50?
Thanks!!