Let be a two dimensional array declared as follows:
A: array [1 …. 10] [1 ….. 15] of integer;
Assuming that each integer takes one memory location, the array is stored in row-major order and the first element of the array is stored at location , what is the address of the element ?
View worked solution
Answer: A
To find the memory address of the element in a 2D array stored in row-major order, we use the standard address calculation formula.
1. Given Parameters
- Array Declaration:
- Number of rows ():
- Number of columns ():
- Lower bound of row index ():
- Lower bound of column index ():
- Base Address ():
- Size of each element (): memory location
2. Row-Major Address Formula
In row-major order, elements are stored row by row. To reach the element , we must skip complete rows (each containing elements) and then skip elements in the current row.
3. Calculation
Substitute the given values into the formula:
Thus, the correct option is A.
Free practice · Your answers on this page are not saved.
