Year 2024
An array ARR[-5…15, 10…20] stores elements in Row Major Wise with each element requiring 2 bytes of storage. Find the address of ARR[10][15] when the base address is 2500.
C = 20 – 10 + 1 = 11
Address of ARR[10][15] = B + W[C(I – Lr) + (J – Lc)]
= 2500 + 2[11(10 – (-5)) + (15 – 10)]
= 2500 + 2[11(15) + 5]
= 2500 + 2[165 + 5]
= 2500 + 2[170]
= 2500 + 340
= 2840
Year 2023
A matrix M[-6…10, 4…15] is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1025, find the address of M[4][8] when the matrix is stored in column major wise.
B = 1025, Lr = -6, Lc = 4, R = 10 – (-6) + 1 = 10 + 6 + 1 = 17
I = 4, J = 8, W = 4
Address of M[4][8] = B + W[R(J – Lc) + (I – Lr)]
= 1025 + 4[17(8 – 4) + (4 – (-6))]
= 1025 + 4[17 × 4 + (4 + 6)]
= 1025 + 4[68 + 10]
= 1025 + 4 × 78
= 1025 + 312
= 1337
Year 2022
A matrix MAT[10][15] is stored in the memory in row major wise with each element requiring 2 bytes of storage. If the base address at MAT[1][2] is 2215, then the address of MAT[3][7] will be?
B = 2215, Lr = 1, Lc = 2, C = 15, I = 3, J = 7, W = 2
Address of MAT[3][7] = B + W[C(I – Lr) + (J – Lc)]
= 2215 + 2[15(3 – 1) + (7 – 2)]
= 2215 + 2[15 × 2 + 5]
= 2215 + 2[30 + 5]
= 2215 + 2 × 35
= 2215 + 70
= 2285
Year 2021
A matrix M[-2…7, 2…10] is stored in the memory with each element requiring 2 bytes of storage. If the base address is 2140, find the address of M[5][6] when the matrix is stored in row major wise.
B = 2140, Lr = -2, Lc = 2, C = 10 – 2 + 1 = 9, I = 5, J = 6, W = 2
Address of M[5][6] = B + W[C(I – Lr) + (J – Lc)]
= 2140 + 2[9(5 – (-2)) + (6 – 2)]
= 2140 + 2[9 × 7 + 4]
= 2140 + 2[63 + 4]
= 2140 + 2 × 67
= 2140 + 134
= 2274
Year 2020
A matrix B[10][20] is stored in the memory with each element requiring 2 bytes of storage. If the base address at B[2][1] is 2140, find the address of B[5][4] when the matrix is stored in column major wise.
B = 2140, Lr = 2, Lc = 1, R = 10, I = 5, J = 4, W = 2
Address of B[5][4] = B + W[R(J – Lc) + (I – Lr)]
= 2140 + 2[10(4 – 1) + (5 – 2)]
= 2140 + 2[10 × 3 + 3]
= 2140 + 2[30 + 3]
= 2140 + 2 × 33
= 2140 + 66
= 2206
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.
B = 1430, Lr = -4, Lc = 3, C = 8 – 3 + 1 = 6, I = 3, J = 6, W = 4
Address of ARR[3][6] = B + W[C(I – Lr) + (J – Lc)]
= 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
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.
B = 1500, Lr = 1, Lc = 1, R = m, I = 4, J = 5, W = 4, Address of A[4][5] = 1608
Address of A[4][5] = B + W[R(J – Lc) + (I – Lr)]
⇒ 1608 = 1500 + 4[m(5 – 1) + (4 – 1)]
⇒ 1608 = 1500 + 4[4m + 3]
⇒ 1608 = 1500 + 16m + 12
⇒ 1608 = 1512 + 16m
⇒ 96 = 16m
⇒ 6 = m
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.
B = 1400, Lr = 0, Lc = 0, C = 10, I = 10, J = 7, W = 8
Address of P[15][10] = B + W[C(I – Lr) + (J – Lc)]
= 1400 + 8[10(10 – 0) + (7 – 0)]
= 1400 + 8[10 × 10 + 7]
= 1400 + 8[100 + 7]
= 1400 + 8 × 107
= 1400 + 856
= 2256
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.
B = 1500, Lr = 1, Lc = 1, R = m, I = 4, J = 5, W = 4, Address of A[4][5] = 1608
Address of A[4][5] = B + W[R(J – Lc) + (I – Lr)]
⇒ 1608 = 1500 + 4[m(5 – 1) + (4 – 1)]
⇒ 1608 = 1500 + 4[4m + 3]
⇒ 1608 = 1500 + 16m + 12
⇒ 1608 = 1512 + 16m
⇒ 96 = 16m
⇒ 6 = m
Year 2015
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.
B = 4110, Lr = -2, Lc = 3, R = 10 – (-2) + 1 = 13, I = 4, J = 5, W = 8
Address of D[4][5] = B + W[R(J – Lc) + (I – Lr)]
= 4110 + 8[13(5 – 3) + (4 – (-2))]
= 4110 + 8[26 + 6]
= 4110 + 8 × 32
= 4110 + 256
= 4366
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.
Address at AR[2][3] = 4142, Lr = -4, Lc = -2, C = 12 – (-2) + 1 = 15, I = 2, J = 3, W = 2
Address of AR[2][3] = B + W[C(I – Lr) + (J – Lc)]
⇒ 4142 = B + 2[15(2 – (-4)) + (3 – (-2))]
⇒ 4142 = B + 2[15(2 + 4) + (3 + 2)]
⇒ 4142 = B + 2[90 + 5]
⇒ 4142 = B + 2 × 95
⇒ 4142 = B + 190
⇒ B = 3952
Year 2013
A square matrix M[][] of size 10 is stored in the memory with each element requiring 4 bytes of storage. If the base address at M[0][0] is 1840, determine the address at M[4][8] when the matrix is stored in row major wise.
B = 1840, Lr = 0, Lc = 0, C = 10, I = 4, J = 8, W = 4
Address of M[4][8] = B + W[C(I – Lr) + (J – Lc)]
= 1840 + 4[10(4 – 0) + (8 – 0)]
= 1840 + 4[10 × 4 + 8]
= 1840 + 4 × 48
= 1840 + 192
= 2032
Year 2012
A matrix B[10][7] is stored in the memory with each element requiring 2 bytes of storage. If the base address at B[x][1] is 1012 and the address at B[7][3] is 1060, determine the value ‘x’ where the matrix is stored in column major wise.
Address at B[7][3] = 1060, B = 1012, Lr = x, Lc = 1, R = 10, I = 7, J = 3, W = 2
Address at B[7][3] = B + W[R(J – Lc) + (I – Lr)]
⇒ 1060 = 1012 + 2[10(3 – 1) + (7 – x)]
⇒ 1060 = 1012 + 2[20 + 7 – x]
⇒ 1060 = 1012 + 2[27 – x]
⇒ 1060 = 1012 + 54 – 2x
⇒ 1060 = 1066 – 2x
⇒ -6 = -2x
⇒ 3 = x
Year 2011
A square matrix A[m × m] is stored in the memory with each element requiring 2 bytes of storage. If the base address A[1][1] is 1098 and the address at A[4][5] is 1144, determine the order of the matrix A[m × m] when the matrix is stored in Column Major Wise.
Address of A[4][5] = B + W[r(J – Lc) + (I – Lr)]
⇒ 1144 = 1098 + 2[m(5 – 1) + ( 4 – 1)]
⇒ 1144 = 1098 + 2[4m + 3]
⇒ 1144 = 1098 + 8m + 6
⇒ 1144 = 1104 + 8m
⇒ 40 = 8m
⇒ m = 5.
So, the order of the matrix is 5 × 5.
Year 2010
A character array B[7][6] has a base address 1046 at 0, 0. Calculate the address at B[2][3] if the array is stored in Column Major Wise. Each character requires two bytes of storage.
Address of B[7][6] = B + W[r(J – Lc) + (I – Lr)]
= 1046 + 2[7(3 – 0) + (2 – 0)]
= 1046 + 2[21 + 2]
= 1046 + 46
= 1092.