‹ Back to the paper
A matrix A[m][m] is stored in the memory with each element requiring 4 bytes of storage. If the…
A matrix A[m][m] is stored in the memory with each element requiring 4 bytes of storage. If the base address at A[1][1] is 1500 and the address of A[4][5] is 1608, determine the order of the matrix when it is stored in Column Major Wise.
Answer
Answer
AIGiven: matrix A[m][m], W=4 bytes, Base Address A[1][1]=1500, Address of A[4][5]=1608, Column Major storage.
Column Major formula (lower bound 1 for both row and column):
Address(A[i][j]) = Base + W x [(j-1) x M + (i-1)], where M = number of rows = m (order of the square matrix)
Here i=4, j=5:
1608 = 1500 + 4 x [(5-1) x m + (4-1)]
108 = 4 x (4m+3)
27 = 4m+3
4m = 24
m = 6
So the order of the matrix is 6 x 6.
Final answer: 6 x 6
From ISC 2018 Computer Science Paper 1, question 2(b).