Answer
See the explanation
Work Step by Step
Given a 2D array representation of a matrix in column major order and its dimensions, what is the correct formula to access the element at position (i, j)?
A) element = matrix[j * rows + i]
B) element = matrix[i * columns + j]
C) element = matrix[i * rows + j]
D) element = matrix[j * columns + i]
Correct Answer: B) element = matrix[i * columns + j]
Explanation: In column major order, elements are stored column-wise, so to access the element at position (i, j), we need to multiply the row index (i) by the number of columns and add the column index (j). Therefore, the correct formula is element = matrix[i * columns + j].