‹ Back to the paper
A matrix is stored in the memory with each element requiring 2 bytes of storage. If the base…
A matrix $M[-1...10, 4....13]$ is stored in the memory with each element requiring 2 bytes of storage. If the base address is 1200, find the address of $M[2][7]$ when the matrix is stored Row Major Wise.
Answer
Answer
AIRow range $-1$ to $10$ $\to$ number of rows $M = 10-(-1)+1 = 12$
Column range $4$ to $13$ $\to$ number of columns $N = 13-4+1 = 10$
Each element $W = 2$ bytes; Base address $=1200$; target $M[2][7]$
Row Major formula: $Address(M[i][j]) = Base + W \times [(i - L_r) \times N + (j - L_c)]$
Here $i=2, j=7, L_r=-1, L_c=4$
$= 1200 + 2 \times [(2-(-1)) \times 10 + (7-4)]$
$= 1200 + 2 \times [30 + 3]$
$= 1200 + 66$
Final answer: 1266
Final answer: 1266
From ISC 2025 Computer Science Paper 1, question 2(ii).