935 views
0 votes
0 votes
An array A[10][20] starts at decimal address 1000. Each element of array occupies 1 B and array is stored in row major order. Compute address of A[5][6]

just give the output.No need very big derivation

2 Answers

1 votes
1 votes
For 1-indexed array

Addr(A[5][6])=1000+20*4+5

                    = 1085

For 0-indexed array

Addr(A[5][6])=1000+20*5+6

                    = 1106
edited by
0 votes
0 votes
in row major order

add(A[i][j]=(i*n+j)*w+base      (where array is of order M*N and we assume that indexing starts with zero)

add[5][6]=(5*20+6)*1+1000

             = 1106

and when indexing is starts with 1

we use add(A[i][j])=((i-1)*n+(j-1))*w+base       (where w is the size of an element in byte)

add[5][6]=(4*20+5)*1+1000

             =1085

Related questions

0 votes
0 votes
2 answers
2
worst_engineer asked Dec 29, 2015
3,798 views
My question is : in the row [8][-8] to [8][5] will be 5-(-8)+1 = 14 elements , right ? so , it should be 1060 then considering 4 Byte is one element.I know , this is pret...
6 votes
6 votes
0 answers
3
V pandey asked Oct 8, 2022
3,049 views
Consider a multi-dimensional array A [90][30]40] with base address start at 1000, calculate the address of A[10][20][3] in row major order and column major order. Assume ...
0 votes
0 votes
1 answer
4
viral8702 asked Apr 29, 2022
484 views
A frame buffer array is addressed in row major order for a monitor with pixel locations starting from (0,0) and ending with (100,100). What is address of the pixel(6,10)?...