Memory Address Excercises
Memory Address Excercises
Row-major Implementation
In this method, the first row elements are placed first, then the second row elements and so on.
Column-major Implementation
In this method, the first column elements are placed first, then the second column elements and so on.
Note that:
B is the base address (address of the first block in the array).
W is the width in bytes (size in bytes for each block in the array).
L is the index of the first row.
r
BASE=2140
C=20
R=10
I=5
J=4
Lc=1
Lr=2
⇒ W[110] = 440
⇒ W = 4.
ISC Year 2019: 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 of ARR[3][6]
when the matrix is stored in Row Major Wise.
Number of columns, C = 8 – 3 + 1 = 6.
B=1430,W=4,I=3,J=6,Lr=-4,Lc=3
Address of [I, J]th element in row-major = B + W[C(I – Lr) + (J – Lc)]
⇒ Address of ARR[3][6] = 1430 + 4[6(3 – (-4)) + (6 – 3)]
⇒ Address of ARR[3][6] = 1430 + 4[6(3 + 4) + 3]
⇒ Address of ARR[3][6] = 1430 + 4[6(7) + 3]
⇒ Address of ARR[3][6] = 1430 + 4[42 + 3]
⇒ Address of ARR[3][6] = 1430 + 4[45]
⇒ Address of ARR[3][6] = 1430 + 180
⇒ Address of ARR[3][6] = 1610.
ISC Year 2018: A matrix A[m][m] is stored in the memory with each element requiring 4 bytes
of storage.If the base address at A[1][1] is 1500 and the address of A[4][5] is 1608, determine
the order of the matrix when it is stored in Column Major Wise.
Address of [I, J] element in column-major = B + W[R(J – L ) + (I – L )]
th
c r
ISC Year 2017: A matrix P[15][10] is stored with each element requiring 8
bytes of storage. If the base address at P[0][0] is 1400, determine the address
at P[10][7] when the matrix is stored in Row Major Wise.
BASE=1400
W=8
C=10
R=15
I=10
J=7
Lc=0
Lr=0
B + W[C(I – L ) + (J – L )]
r c
ISC Year 2016: A matrix A[m][n] is stored with each element requiring 4 bytes of storage. If the base address at A[1][1] is
1500 and the address at A[4][5] is 1608, determine the number of rows of the matrix when the matrix is stored in Column
Major Wise.
Address of [I, J] element in column-major = B + W[R(J – L ) + (I – L )]
th
c r
The array D[-2…10][3…8] contains double type elements. If the base address
is 4110, find the address of D[4][5], when the array is stored in Column Major Wise.
Number of rows, R = 10 – (-2) + 1 = 13.
Address of [I, J] element in column-major = B + W[R(J – L ) + (I – L )]
th
c r
ISC Year 2014: An array AR[-4 … 6, -2 … 12], stores elements in Row Major Wise, with the address AR[2][3] as 4142. If
each element requires 2 bytes of storage, find the Base address.
Number of columns, C = 12 – (-2) + 1 = 12 + 2 + 1 = 15.
Address of [I, J] element in row-major = B + W[C(I – L ) + (J – L )]
th
r c