Explore BrainMass

Entry in a Homogeneous Array

Suppose that a homogeneous array with 6 rows and 8 columns, is stored in row major order starting at address 20 (base ten). If each entry in the array requires only one memory cell, what is the address of the entry in the third row and fourth column? What if each entry requires two memory cells?

Solution Preview

For a two dimension homogenous array stored in row major ordering, we compute the address of an array entry Arr[i][j] as

= ArrayBase + (i - 1) * (Ncolumns * Se) + (j - 1) * Se
= ArrayBase + Se * ((i - 1) * Ncolumns + (j - 1))


ArrayBase = starting address of the array
Se = size of single entry
Ncolumns = maximum number of columns per row
i, j = row and column indices respectively, assumed to start from 1.

In the ...