in Programming retagged by
16,629 views
3 votes
3 votes

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$ 
in Programming retagged by
16.6k views

3 Answers

5 votes
5 votes
Best answer

Each cell needs 4 words

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

Answer is A

selected by
by

4 Comments

Can you explain in detail bro
0
0
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
2
2

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 

0
0
0 votes
0 votes

row and coloum major

0 votes
0 votes

A[20][10]

to reach A[11][5]

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[11][5] = base address + space occupied by elements before it$

                                $=100+460=560$

option (A)

by
Answer:

Related questions