A matrix ARR[-4....6,3...8] is stored in the memory with each element
requiring 4 bytes of storage. If the base address is 1430. find the address ofARR[3][6] when the matrix is stored in Row Major Wise.
Answers
Answer:
Here is my answer
Explanation:
8] is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1430, find the address of ARR[3][6] when the matrix is stored in Row Major Wise. Number of columns, C = 8 – 3 + 1 = 6. ⇒ Address of ARR[3][6] = 1610.
Given:
ARR[-4....6 , 3....8]
W = 4
B = 1430
I = 3
J = 6
Lr = -4
Lc = 3
To find:
The address of ARR[3][6] when the matrix is stored in Row Major Wise.
Solution:
No. of columns (C) = 8 - 3 + 1 = 6
Address of [I , J]th element in row major = B + W[C(I - Lr) + (J - Lc)]
ARR[3][6] = 1430 + 4[6(3 - (-4) + (6 - 3)]
= 1430 + 4[6(3 + 4) + 3)
= 1430 + 4[6(7) + 3]
= 1430 + 4[42 + 3]
= 1430 + 4[45]
= 1430 + 180
= 1610
So, the address of ARR[3][6] is 1610 when the matrix is stored in Row Major Wise.