Address in multi dimensional array

What is the formula to calculate address in multi dimensional array ?

  • Rahul
  • 20 Feb
  • 79165 Views
  • 3 Answers
Your Answer

Let us consider your array be A[x][y][z] starting with 0 indices. We have to find address of A[p][q][r] : A[p][q][r] = ( (p*y + q) *z + r) * size + base . if you have array not starting with 0 index . lets say A[x1:x2][y1:y2][z1:z2] then A[p][q][r] = (((p-x1)*(y2-y1+1) +(q-y1))*(z2-z1+1) +(r-z1)) * size + base.

-1
Data Structure

Didn't get the answer.
Contact people of Talent-Data Structure directly by clicking here