DS

Introduction of Array

An array is an aggregate data structure that is designed to store a group of objects of the same or different types. Arrays can hold primitives as well as references. The array is the most efficient data structure for storing and accessing a sequence of objects.

Row Major and Column Major Arrays


In computing, row-major order and column-major order describe methods for arranging multidimensional arrays in linear storage such as memory.

In row-major order, consecutive elements of the rows of the array are contiguous in memory; in column-major order, consecutive elements of the columns are contiguous.

Array layout is critical for correctly passing arrays between programs written in different languages. It is also important for performance when traversing an array because accessing array elements that are contiguous in memory is usually faster than accessing elements which are not, due to caching. In some media such as tape or NAND flash memory, accessing sequentially is orders of magnitude faster than nonsequential access.

Explanation and example

Following conventional matrix notation, rows are numbered by the first index of a two-dimensional array and columns by the second index, i.e., a1,2 is the second element of the first row, counting downwards and rightwards. (Note this is the opposite of Cartesian conventions.)

The difference between row-major and column-major order is simply that the order of the dimensions is reversed. Equivalently, in row-major order the rightmost indices vary faster as one steps through consecutive memory locations, while in column-major order the leftmost indices vary faster.
 

This array
tutorialink

would be stored as follows in the two orders:

Row Major Array Order

Address Value
0 a11
1 a12
2 a13
3 a21
4 a22
5 a23

Column Major Array Order

Address Value
0 a11
1 a21
2 a12
3 a22
4 a13
5 a23



Subscribe us on Youtube

Share This Page on

Question


Jean dumol | 24-Jun-2018 04:54:50 pm

Hi! may i know how to make the flowchart to this update operation?Thanx


Ask Question