Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




What are the ways of representing 2D array in memory? Explain each one of them with examples

A 2D array’s elements are stored in continuous memory locations. It can be represented in memory using any of the following two ways:

1. Column-Major Order
2. Row-Major Order

1. Column-Major Order:
In this method the elements are stored column wise, i.e. m elements of first column are stored in first m locations, m elements of second column are stored in next m locations and so on. E.g.
A 3 x 4 array will stored as below:





2. Row-Major Order:

In this method the elements are stored row wise, i.e. n elements of first row are stored in first n locations, n elements of second row are stored in next n locations and so on. E.g.

A 3 x 4 array will stored as below:

Share this article   |    Print    |    Article read by 42200 times
Author:
Rohit kakria
I am software developer
Related Articles: No related article
Related Interview Questions: No related interview question