10,187 views
39 )

Suppose a multidimensional array is declared as m(2:8,-4:1,6:10). If the base address is 200 and there are 4 words per memory location, then the address of A[5,-1,8] by using row order is ______.

multidimensional array is declared as m(2:8,-4:1,6:10)

How do we interpret this sentence?
It is interpreted as :-

A 3-D array whose frame no. Starts from 2 and ends at 8.

Total no. Of frames = (8-2+1)=7

In each frame, there are (-4:1,6:10) rows and columns respectively.

Which means (1-(-4)+1)=6 rows and (10-6+1)=5 columns.

Ultimately, there are 7 frames and each has 6 rows and 5 columns.

You can refer to the answer's diagram to get an idea.
In A[i][j][k] an array of 3 dimensions isnt i == row, j== column and k== height or frame ;

In above question it is represented as i== height , j== row  and k==column.

I have drawn a sketch of 3-D array to give a rough idea about how it looks like..it consists of many 2-D arrays also referred as Frames.

First see the no. of frames already crossed(given by the 1st dimension).. this means finding out how many elements of frames have already been covered. For that find (no. Of rows * no. Of columns)*no. Of frames given.

After reaching that particular frame, treat the sum as a simple 2-D array sum. Address = B.A + ((i-LSB)_2D_arrays*no._elements_In_1_2D_Array*instsize + (k-LSB)*no._of_rows*intsize + (j-LSB)*intsize)

The bold parts are the correction. You were almost right :)

Given a 3D array A[1:8,-5:5,-10:5] stored in a column major order, if the base address is 400 and size of an element is 4 byte, what is the address of A?

I'm also getting 2412

CMO=(11*16*2+13*11+8)*4+400

What is the correct answer? Column major order

## put the value and find the answer,anwer will come in this case 628

Address calculation for N-D Array 