‹ Back to the paper
A matrix is stored in the memory with each element requiring 4 bytes of storage. If the base…
A matrix $M[-6 \dots 10, 4 \dots 15]$ is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1025, find the address of $M[4][8]$ when the matrix is stored in column major wise.
Answer
Answer
Official answer keyColumn Major formula: Address(M[I][J]) = B + W x [(J - Lc) x M + (I - Lr)], where M = number of rows.
Row range -6 to 10 => M = 10 - (-6) + 1 = 17
Column range 4 to 15 => N = 15 - 4 + 1 = 12 (not needed further, column major)
Given: B = 1025, W = 4, I = 4, J = 8, Lr = -6, Lc = 4
Address(M[4][8]) = 1025 + 4 x [(8-4) x 17 + (4-(-6))]
= 1025 + 4 x [4 x 17 + 10]
= 1025 + 4 x [68 + 10]
= 1025 + 4 x 78
= 1025 + 312
= 1337
Final answer: 1337
From ISC 2025 Specimen Computer Science Paper 1, question 2(ii).