Practice mode Data Structures

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

Correct answer C. 1260

Explanation

In row-major order, whole rows are stored one after another, so address = base + (i × number of columns + j) × size. Here that is 1000 + (3 × 20 + 5) × 4 = 1000 + 65 × 4 = 1260. The value 1212 is what column-major order would give, a common slip when the storage order is misread.

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.