‹ Back to the paper
Solve the following.
Each element of an array arr[15][20] requires 'W' bytes of storage. If the address of arr[6][8] is…
Each element of an array $arr[15][20]$ requires '$W$' bytes of storage. If the address of $arr[6][8]$ is 4440 and the Base Address at $arr[1][1]$ is 4000, find the width '$W$' of each cell in the array $arr[ ][ ]$ when the array is stored as Column Major Wise.
Answer
Answer
Column major formula: Address of $arr[I][J] = BA + W \times [(J - L_c) \times M + (I - L_r)]$
Given: number of rows $M = 15$, $BA = 4000$ at $arr[1][1]$ so $L_r = 1$, $L_c = 1$; $I = 6$, $J = 8$; address of $arr[6][8] = 4440$.
$4440 = 4000 + W \times [(8 - 1) \times 15 + (6 - 1)]$
$4440 = 4000 + W \times [105 + 5]$
$440 = 110 \times W$
$W = 440 / 110 = 4$ bytes
Final answer: 4 bytes