##### How to calculate 3-d address?

Consider 3 dimensional Array A   stored in linear array in column major order. If the base address starts at 10.

The location of A   is __________ . [Assume the first element is stored at A and each element take 1 B]

how to calculate 3d address .

Akshay Saxena
11 Aug 2017 08:29 pm

3 Dimnesional array is nothing but collection of 2 dimensional array * no of times . For example in this question : A is the collection of 20 arrays with rows 20 and columns 30. Calculate it that aspect since it is column major :
10+19*20*30+29*20+19

set2018
12 Aug 2017 12:58 pm

not getting yet :(

see.arr means we have 3 tables of 2d array which comprises of 3*3 (3 rows 3 columns ) i know the method to solve address for 2 d array but in this case m not geting :(

shivani
11 Aug 2017 10:01 pm

let us consider 3-d array[i,j,k] as modified form of 2-d array[i',j'] wher i' is a 2-d array[i,k]

now, we can can now solve easily by column major order of arr[m,n,p] :
= base address + (j-1)*size of element(n,p) + (i-1)*size of element(p) + k

= 10+ (20-1)*90*40 + (20-1)*40 + 30  = 69200

set2018
13 Aug 2017 12:40 pm
set2018
13 Aug 2017 12:41 pm

for this question i assume (A[1...90,1....30,1...........40])

and applying same technique

but got 80039

Ashish Kumar Goyal
22 Aug 2018 04:15 pm

I guess we can refer this as a standard based on C(for Row-major) and Fortran(for Column major) compilers-

"The concept generalizes to arrays with more than two dimensions.

For a d-dimensional array with dimensions N(k=1...d), a given element of this array is specified by a tuple of d (zero-based) indices .

In row-major order, the last dimension is contiguous, so that the memory-offset of this element is given by: In column-major order, the first dimension is contiguous, so that the memory-offset of this element is given by: where the empty product is the multiplicative identity element, i.e., "