Matrix Representation Order — The Intuition First
Imagine you're a teacher taking attendance. You have a list of 5 students and you call out their names one by one. The order matters — "Ravi, Priya, Anjali, Vikram, Sneha" is a specific sequence. If you wrote that sequence down, you'd have an ordered list.
Now imagine you're arranging those same 5 students into rows and columns for a class photo. You decide: 2 rows, 3 columns (one spot empty). The moment you fix how many rows and how many columns, you've chosen a matrix shape. But here's the key: the order in which you fill those slots — row by row, or column by column — changes who ends up where.
That's the core idea of matrix representation order: given a list of numbers (or objects), the same list can be arranged into a matrix in different ways depending on whether you fill it row-wise or column-wise.
The Precise Statement
A matrix of size m×n has m rows and n columns, so it holds m×n entries. If you have a sequence of m×n elements, there are two standard ways to map them into the matrix:
Row-major order: Fill the first row left to right, then the second row left to right, and so on.
Column-major order: Fill the first column top to bottom, then the second column top to bottom, and so on.
Let the sequence be a1,a2,a3,…,amn. In row-major order, the element at position (i,j) — meaning row i, column j — is:
a(i−1)n+j
In column-major order, the element at (i,j) is:
a(j−1)m+i
These formulas are not something to memorise blindly. They come from counting: in row-major, you skip (i−1) full rows (each of n elements) and then take the j-th element of that row. In column-major, you skip (j−1) full columns (each of m elements) and then take the i-th element of that column.
A Concrete Example
Take the sequence: 1,2,3,4,5,6. Put it into a 2×3 matrix.
Row-major (fill rows first):
[142536]
Column-major (fill columns first):
[123456]
Same six numbers, completely different matrices. The order of filling changes the arrangement.
A common mistake is to assume that "matrix representation order" means the order of rows and columns in the final matrix. It does not — it means the order in which you place the input data into the matrix slots.
Why This Matters …