‹ Back to the paper
A matrix ARR[ – 4…6, 3….8] is stored in the memory with each element requiring 4 bytes of storage…
A matrix ARR[ – 4…6, 3….8] 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
AIRow 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
Final answer: 1610
From ISC 2019 Computer Science Paper 1, question 2(b).