Prashnikaप्रश्निका
Code
About
‹ Back to the paper
Computer Science20232 marksNumericalArrays, StringsTool: 2D array visualiser

Answer the following.

A matrix M[-6… 10, 4… 15] is stored in the memory with each element requiring 4 bytes of storage…

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

Column Major formula: Address(M[I][J]) = Base + W × [ (J - LC) × NR + (I - LR) ] LR = -6, UR = 10, so NR = 10 - (-6) + 1 = 17; LC = 4; W = 4, Base = 1025, I = 4, J = 8. Address(M[4][8]) = 1025 + 4 × [ (8 - 4) × 17 + (4 - (-6)) ] = 1025 + 4 × [ 68 + 10 ] = 1025 + 4 × 78 = 1025 + 312

Final answer: 1337