Sunday, October 11, 2009

ADDRESS CALCULATION OF ARRAY ELEMENT A [J][K]

The computer keeps track of Base (A), the address of the first element

A[0][0] of A[M][N], and computes address Loc (A[J][K]) of A[M][N] using the formula

Column–Major Order:

Loc (A[J][K] ) = Base (A) + W [M x K + J ]

OR

ROW MAJOR ORDER:

Loc (A [J][K]) = Base (A) + W [N x J + K ]

W denotes the size, i.e; number of bytes per data element of the array A, M is total numbers of rows, and N is total number of columns in the array.

3 comments:

  1. Row Major Order:-
    Base Address + Element Size[no. of column(i-lower bound of row)+(j-lower bound of column)]

    Column Major Order:-
    Base Address + Element Size[no. of row(j-lower bound of column)+(i-lower bound of row)]

    ReplyDelete
  2. http://www.javaforschool.com/625348-memory-address-calculation-in-an-array/

    ReplyDelete