Prashnikaप्रश्निका
Code
About
‹ Back to the paper
Computer Science20262 marksNumericalArrays, Strings

Answer the following.

An array Arr[3 … 8, -5 … 5] is stored Row Major Wise. The address of Arr[5][-2] is 5120. If each…

An array $Arr[3 \dots 8, -5 \dots 5]$ is stored Row Major Wise. The address of $Arr[5][-2]$ is $5120$. If each element occupies $4$ bytes in the memory, find the base address of the array.

Answer

Answer

Row Major formula: Addr(Arr[i][j]) = Base + W × [ (i - LR) × NC + (j - LC) ] LR = 3, LC = -5, UC = 5, so NC = 5 - (-5) + 1 = 11; W = 4, i = 5, j = -2. Addr(Arr[5][-2]) = Base + 4 × [ (5 - 3) × 11 + (-2 - (-5)) ] 5120 = Base + 4 × [ 22 + 3 ] 5120 = Base + 4 × 25 5120 = Base + 100 Base = 5120 - 100 = 5020

Final answer: 5020