Advertisements
Advertisements
Question
A matrix M[–1...10, 4....13] is stored in the memory with each element requiring 2 bytes of storage. If the base address is 1200, find the address of M[2][7] when the matrix is stored Row Major Wise.
Numerical
Advertisements
Solution
Row-Major order formula:
Address = Base Address [(i − Lr) × Total Columns (j − Lc)] × Element Size
Putting the values in given formula,
Lr = −1, Lc = 4, i = 2, j = 7,Total Columns = 10, Element Size = 2.
After putting the values
Address = 1200 + [(2 – (– 1)) × 10 + (7 − 4)] × 2
= 1200 + [(2 + 1) × 10 + 3] × 2
= 1200 + [3 × 10 + 3] × 2
= 1200 + 33 × 2
= 1266
shaalaa.com
Is there an error in this question or solution?
2024-2025 (March) Official Board
