4.2 2D-Array There are three ways to implement a 2D array 1)mapping the 2D-array to a lD-array 00 aoo ao a 0m-1 01 10alla12……a1m a20aa21a22 a 2m-1 Row major order 11 0
4.2 2D-Array There are three ways to implement a 2D array 1) mapping the 2D-array to a 1D-array a00 a01 a02……a0 m-1 a10 a11 a12……a1 m-1 a20 a21 a22……a2 m-1 …………. an-10 an-11an-12…..an-1 m-1 a00 a01 … a0 m-1 a10 a11 …. an-1 m-1 Row major order
4.2 2D-Array Location mapping a)row-major order Loc(a订)=Loc(a[00])+[i*m+订*1 b)column-major order Loc(ajlD=loc(a[ojo+n+i]*I
4.2 2D-Array Location mapping: a) row-major order Loc(a[i][j])=Loc(a[0][0])+[i*m+j]*l b) column-major order Loc(a[i][j])=Loc(a[0][0])+[j*n+i]*l
4.2 2D-Array Dusing a pointer to a pointer to an element For example [2][31[4 [0] X[1 [2] Memory structure for a three by five arra
4.2 2D-Array 2)using a pointer to a pointer to an element For example: X[0] X[1] X[2] [0] [1] [2] [3] [4] Memory structure for a three by five array
4.2 2D-Array 3 using array of ID-arrays Each element of the 2d array is a 1D array
4.2 2D-Array 3)using array of 1D-arrays Each element of the 2D array is a 1D array
4.2 2D-Array An 3D-array int amm2lm3 Location mapping Loc(ajllkkd=Loc(a[0J[oJ[o]+i*m2*m3+j*m3+k
4.2 2D-Array An 3D-Array: int a[m1 ][m2 ][m3 ] Location mapping Loc(a[i][j][k])=Loc(a[0][0][0])+i*m2*m3+j*m3+k