Page 310 - Computer science 868 Class 12
P. 310
= 1500 + 1 * [160]
= 1660
(ii) Row Major Wise Calculation of the above equation
The given values are: B = 1500, W = 1 byte, I = 15, J = 20, Lr = -15, Lc = 15, N = 26
Address of A [ I ][ J ] = B + W * [ N * ( I - Lr ) + ( J - Lc ) ]
= 1500 + 1* [26 * (15 - (-15))) + (20 - 15)]
= 1500 + 1 * [26 * 30 + 5]
= 1500 + 1 * [780 + 5]
= 1500 + 785
= 2285
2. Given an array, arr[1………10][1………15] with base value 100 and the size of each element is 1 Byte in memory.
Find the address of arr[8][6] with the help of row-major order.
Solution:
Given:
B = 100
W = 1 Bytes
I = 8
J = 6
LR = 1
LC = 1
Number of columns given in the matrix N = Upper Bound – Lower Bound + 1
= 15 - 1 + 1
= 15
Formula:
Address of A[I][J] = B + W * ((I - LR) * N + (J - LC))
Ans. Address of A[8][6]
= 100 + 1 * ((8 - 1) * 15 + (6 - 1))
= 100 + 1 * ((7) * 15 + (5))
= 100 + 1 * (110)
= 210
Questions related to Address Calculations
1. Given the base address of an array B[1400…..1800] as 1020 and the size of each element is 2 bytes in the
memory. Find the address of B[1700].
2. Given the base address of array B[1500…..3000] as 1260 and the size of each element is 2 bytes in the memory.
Find the address of B[2200] and B[2000].
3. The array D[-2…10][3…8] contains double type elements. If the base address is 4110. Find the address D[4][5],
when the array is stored in column major wise.
4. An array AR[-4…6, -2 … 12] stores elements in Row Major wise, with the address of AR[2][3] as 4142. If each
element requires 2 bytes of storage. Find the base address.
5. 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 of ‘x’ where the matrix is stored column major
wise.
308308 Touchpad Computer Science-XII

