Question Detail

COS 102 test topic Objective Question

Question

Assuming zero-based indexing and row-major order, what is the memory offset of element `A[i][j]` in an array with `C` columns?
Options
A i * C + j
Correct Answer
B j * C + i
C (i + j) * C
D i + j
Correct Answer

Option A is the correct answer.

Detailed Explanation

Row-major storage lays elements row by row; skipping i rows corresponds to i * C elements, plus j column steps.

Hint

No hint available

Question Info