6,360 views
3 votes
3 votes
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)

2 Answers

3 votes
3 votes

For Row Major Order Derivation :-

0 votes
0 votes

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

Source:  https://en.wikipedia.org/wiki/Row-_and_column-major_order

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

   

Referencehttps://en.wikipedia.org/wiki/Row-_and_column-major_order

Related questions

5 votes
5 votes
6 answers
1
Pankaj Joshi asked Jan 26, 2017
15,860 views
Consider 3 dimensional Array A[90] [30] [40] stored in linear array in column major order. If the base address starts at 10. The location of A[20] [20] [30] is __________...
16 votes
16 votes
3 answers
2
shikharV asked Dec 4, 2015
15,594 views
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 __________...
6 votes
6 votes
2 answers
3
Abhisek Tiwari 4 asked Oct 20, 2018
2,263 views
int arr [3] ;print(arr -arr[0],arr [0]-arr[0][0])P.s :Sorry i can't able to paste the question but this is main Context.
4 votes
4 votes
3 answers
4
Hira Thakur asked Nov 19, 2017
902 views
#include<stdio.h int main() { int arr [3] ={{{2,4},{7,8},{3,4},},{{2,2},{2,3},{3,4},}}; print("\n%d", (*arr+1)+2+7); return 0; } plz explain this program, internally how ...