‹ Back to the paper
Question 2(b)
2 marks
Computer ScienceISC 2019 Computer Science Paper 1NumericalArrays, Strings
Solve the following.
A matrix ARR[-4…6, 3…8] is stored in the memory with each element requiring 4 bytes of storage. If…
A matrix $ARR[-4\ldots6, 3\ldots8]$ is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1430, find the address of $ARR[3][6]$ when the matrix is stored in Row Major Wise.
Answer
Answer
Row range $-4$ to $6$ $\to$ number of rows $M = 6-(-4)+1 = 11$
Column range $3$ to $8$ $\to$ number of columns $N = 8-3+1 = 6$
Each element $W = 4$ bytes; Base address $=1430$; target $ARR[3][6]$
Row Major formula: $Address(ARR[i][j]) = Base + W \times [(i - L_r) \times N + (j - L_c)]$
Here $i=3, j=6, L_r=-4, L_c=3$
$= 1430 + 4 \times [(3-(-4)) \times 6 + (6-3)]$
$= 1430 + 4 \times [42 + 3]$
$= 1430 + 4 \times 45$
$= 1430 + 180$
Final answer: 1610