Practice mode Data Structures

A two-dimensional array A of 4-byte elements is stored in column-major order starting at address 1000, with indices starting at 0. What is the address of A?

Correct answer A. 1212

Explanation

In column-major order, whole columns are stored consecutively, so address = base + (j × number of rows + i) × size. That gives 1000 + (5 × 10 + 3) × 4 = 1000 + 53 × 4 = 1212. Fortran and MATLAB use column-major order, while C and C++ use row-major, which would produce 1260 for the same element.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.