4,298 views
Consider 3 dimensional Array A[90] [30] [40] stored in linear array. If the base address starts at 10, The location of A [20] [20] [30] in case of RMO and CMO are ________. (Assume the first element is stored at A[1][1][1] and each element take 1 memory location)

can u explain what you did for CMO ?

Base Add + (k-1)r1r2 + (j-1)r2 + (i-1).....??
can u please explain how to count in case of 3D ??
For RMO:10+19*30*40+19*40+29

for CMO 10+19*30*40+29*30+19

Please explain how did u solve ?

For Row Major Order Derivation :-

@Shaik Masthan

A is an array [2.....6,2.....8,2.......10] of elements. The starting location is 500. The location of an element A(5,5,5) using column major order is __________.

For this question it should for CMO:

[ (5-2)[(8-2+1)*(10-2+1)] + (5-2)*(8-2+1) + (5-2) ] * size + BA

3*7*9 + 3*7 + 3 + 500 ===> 713

What is wrong in this ? in answer it is 624

first [2...6] will shows that 5 2D array with each 2 array of size [7][9] right ?

how will we take for the column major ??

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 ${\displaystyle N_{1}\times N_{2}\times \cdots \times N_{d}}$ array with dimensions $N_{k} (k=1...d)$, a given element of this array is specified by a tuple $(n_1, n_2, \ldots, n_d)$ of d (zero-based) indices $n_k \in [0,N_k - 1].$

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.,

1
13,328 views