899 views
2 votes
2 votes

How to get address for this ? As i understood till now that we have 90 (2 d array of 30*40) pls explain the concept of calcultaing address for this ?

1 Answer

3 votes
3 votes
For storing a 3-D array in column major order, we'll store planes first, then columns and finally rows.

Consider a 3-D array A[M][N][P] stored as A[d1....dn1][d2...dn2][d3...dn3]

where d1 = lower bound of dimension 1

dn1 = upper bound of dimension 1

d2 = lower bound of dimension 2

dn2 = upper  bound of dimension 2

d3 = lower bound of dimension 3

dn3 = upper bound of dimension 3

Now, an element at location A[i][j][k] in CMO will be found at

Location(A[i][j][k]) = Base address + { (i-d1)*(number of rows)*(number of colums) + (k-d3)* number of rows + (j-d2) } * size of one element

Now, let's do your question!

Assuming one element takes 4 bytes,

Location of A[20][20][30] = 10 + { (20-1)*30*40 + (30-1)*30 + (20-1) }*4 = 94766
edited by

Related questions

1 votes
1 votes
1 answer
2
Na462 asked Aug 22, 2018
2,925 views
Consider array A[1..100,1..100],in which elements are stored in Z representation. An example of 5x5 such array is shown below: Base address of array = 1000,size of each e...
13 votes
13 votes
8 answers
3
Na462 asked Aug 22, 2018
5,570 views
Consider a 2 dimensional array A[40...95,40...95] in lower triangular matrix representation. The size of each element of array is 1 Byte.If array is implemented in memory...
0 votes
0 votes
1 answer
4
iarnav asked Jun 12, 2018
872 views
Given an sorted array in descending order, what will be the time complexity to delete the minimum element from this array?