1,002 views
0 votes
0 votes
Given a 3D array A[2:8,-4:1,6:10] stored in a row major order, if the base address is 200 and size of an element is 4 byte, what is the address of A[5][-2][8]?

 

I AM GETTING ANSWER 616 ANSWER IS 608 ?????? AM I WRONG

3 Answers

1 votes
1 votes
I am also getting 608

A[x][y][z] = A[8-2+1][1-(-4)+1][10-6+1]. So A[7][6][5] is our 3-D array. if we go for row major  order we consider A[planes][row][columns] we need to know the address of A[5][-2][8] which is A[3][2][2] so we need to cross 3 planes means (6*5  elements in one plane) 90 element after that we need to cross 2 rows (= 10 elements) and 2 column element so the total element we need to cross is

(3*6*5)+(5*2)+2 =102

so the address of A[3][2][2] will be = 200+(102*4) = 608
1 votes
1 votes

I think it will help you

No related questions found