InterviewSolution
Saved Bookmarks
| 1. |
An array P[30][20] is stored along the column in the memory with each element requiring 2 bytes of storage. If the base address of the array P is 26500, find out the location of P[20] [10] |
|
Answer» Total number of rows (R) = 30 Size of each element (W) = 2 Base Address (B) = 26500 Assuming lower bound of row(LBR) = 0 and lower bound of column (LBC) = 0 LOC(P[l][J]) = B+W[(I – LBR) + (J – LBC)*R] LOC(P[20][10]) = 26500 + 2[(20 – 0) + (10 – 0) * 30] = 26500 + 2[20 + 10 x 30] = 26500 + 2[20 +300] = 26500 + 2 x 320 = 26500 + 640 = 27140 Hence, Location of P[20][10] is 27140. |
|