Two dimensional array representation in memory

  • The elements of a two dimensional array are stored in computer’s memory row by row or column by column.
  • If the array is stored as row by row, it is called row-major order.
  • If the array is stored as column by column, it is called column-major order.
  • Suppose there is a two-dimensional array of size 5 × 6. That means, there are 5 rows and 6 columns in the array.
  • In row-major order, elements of a two dimensional array are ordered as –
  • A11, A12, A13, A14, A15, A16, A21, A22, A23, A24, A25, A26, A31, ............, A46, A51, A52, .......,A56.
  • and in column-major order, elements are ordered as –
  • A11, A21, A31, A41, A51, A12, A22, A32, A42, A52, A13, ............, A55, A16, A26, .......,A56.

No comments:

Post a Comment

Followers

About Me

Dhaka, Dhaka, Bangladesh
..