16,629 views

Consider an array $A\left[20, 10\right]$, assume $4$ words per memory cell and the base address of array $A$ is $100$. What is the address of $A\left[11, 5\right]$ ? Assume row major storage.

1. $560$
2. $565$
3. $570$
4. $575$

Each cell needs 4 words

• A, A ,.....A needs 4x10 =40 words.
• Since array starts at 100, A will be at 100+40=140 th location.
• Similarly, from A to A there are 11x10=110 elements.
• From A to Athere are 5 elements.
• Total 115 elements are present before A.
• Hence A will be at 100+ 4x115 = 560

by

Can you explain in detail bro
We can simply use the row-major order formula to find the array address of A[I,J].

Let A[M,N] be the size of the array, w be the word size, then

A[I,J] = Base Address of A + w(I *N + J)

Here, A[M,N] is A[20,10]

So, A[11,5] = 100 + 4(11*10 + 5)

= 100 + 4(115) = 100+460

=560

How the number of columns is 10 and not 11??

0 being 1st column, 10 should be 11th column. Isn’t it?

Number of column given in the matrix N = Upper Bound – Lower Bound + 1 = 10 -0 +1 =11

row and coloum major A

to reach A

we have to cross 11 rows and each row contains 10(no. of columns) elements and in 12th row we have to cross 5 elements

total elements to cross= $11*10+5=115$

each element occupies 4 words space

total space = $4*115=460$

address of $A = base address + space occupied by elements before it$

$=100+460=560$

option (A)

by