edited by
978 views
0 votes
0 votes
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 ________.
(Assume the first element is stored at A[1][1][1] and each element take 1 memory location)
edited by

4 Answers

2 votes
2 votes

A[1...90][1...30][1...40]

LOC(A[20][20][30]) =10 + ((20-1)*30*40 +(30-1)*30 + (20-1)) = 23699

in general for CMO:

A[1...n][1...m][1...o]

loc(A[i][j][k]) = base address + ((i-1)*#f col * #f rows + (k-1)*#f rows + j-1)*size of array

edited by
0 votes
0 votes
To access element $a_{i,j,k}$ in array $A_{p,q,r}$ for RMO with elements starting from 0, use below formula:

$a_{i,j,k} = [i(q+r) + j*r + k] size + base$

Now, modifying it for CMO with elements starting from 1:

$a_{i,j,k} = [(k-1)(p+q) + (j-1)*q + (i-1)] size + base$

I am not sure about it, so you should check it out. But this is what we get if we go with the logic of how we derive for CMO in 2-D array.

Related questions

1 votes
1 votes
2 answers
2
Shamim Ahmed asked Dec 11, 2018
1,241 views
Given a 2D array A[40….95, 40...95] in lower triangular representation, size of each element is 1 ByteArray implemented in row major order, base address is 1000Address ...
1 votes
1 votes
1 answer
3
shivangi5 asked Dec 12, 2017
658 views
Options areTI==(P/Q*i-1)Ti==(P/Q*i+1)Ti==(P/Q*(i-1)-1)Ti==(P/Q*(i+1)-1)
2 votes
2 votes
0 answers
4