The value of the following equation:
BA + [n * (i - LBR) + (j - LBC)] * w
If you have an array A [n] [n] and you know the address of the record A [LBR] [LBC] as BA, then the address A [i] [j] can be calculated as follows. Assuming n = 6,
00 01 02 03 04 05 10 11 12 13 14 15 20 21 22 23 24 25 30 31 32 33 34 35 40 41 42 43 44 45 50 51 52 53 54 55
Here, suppose we know the address A [2,1] = 1000. We need to calculate the address A [4,2]. Now, to reach [4.2] from [2.1], how many records will we need to travel? Of course, as @Deepu points out, we can do this in two ways: either move in rows or in columns. It can be seen from the equation that row row selection was selected.
22 to 25 (4) 30 to 35 (6) 40 to 42.(3) = 13 entries.
Therefore, the address A [4,2] = 1000 + 13 * (numOfbytes per entry)
To check using the equation,
i - LBR = 4 - 2 = 2. j - LBC = 2 - 1 = 1.
Therefore, n*( i - LBR ) + (j - LBC) = 6*2 + 1 = 13.
source share