Multidimensional array, Data Structure & Algorithms

Q. The system allocates the memory for any of the multidimensional array from a big single dimensional array. Describe two mapping schemes that help us to store the two dimensional metrics in the one-dimensional array.    


A two dimensional array is declared similar in the way we declare the one-dimensional array except that we state the number of elements in both the dimensions. For example,

int grades[3][4];

The first bracket ([3]) tells about the compiler that we are declaring in the 3 pointers, each of which is pointing to an array. Here we are not talking about a pointer variable or the pointer array. Instead, here we are saying that each element of the first dimension of the two dimensional array reference a corresponding second dimension. In the example we have, all the arrays pointed to by the first index are having the same size. The second index can be of the variable size. For example, the earlier statement declares a two- dimensional array in which there are 3 elements in the first dimension and 4 elements are there in the second dimension.

Two-dimensional array can be represented in memory in the following two ways:

1. The Row major representation technique: To attain this linear representation, the first row of the array is stored in the first memory locations or addresses reserved for the array, then the second row and so on.

2. The Column major representation technique: In this all the elements of the column are saved next to one another. In the row major representation, the address is calculated and obtained in a two dimensional array as per the following formula

The address of a[i][j]=base(a)+(i*m+ j)*size, where the base(a) is the address or location of a[0][0], m is second dimension of array a and size represent size of the data type.

Posted Date: 7/12/2012 8:31:29 AM | Location : United States

Related Discussions:- Multidimensional array, Assignment Help, Ask Question on Multidimensional array, Get Answer, Expert's Help, Multidimensional array Discussions

Write discussion on Multidimensional array
Your posts are moderated
Related Questions
Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

What is Keyed Access- Container A collection may allow its elements to be accessed by keys. For instance, maps are unstructured containers which allows their elements to be

Explain about the String Abstract data type operations Symbol ADT has no concatenation operations, but presuming we have a full-featured String ADT, symbols can be concatenated

Painter's Algorithm As the name suggests, the algorithm follows the standard practice of a painter, who  would paint the background (such as a backdrop) first, then the major d

Data Structure and Methods: Build an array structure to accomodate at least 10 elements. Provide routines for the following: An initializer. A routine to populate (

Djikstra's algorithm (named after it is discovered by Dutch computer scientist E.W. Dijkstra) resolves the problem of finding the shortest path through a point in a graph (the sour

what is the impoartance of average case analysis of algorithm

In the array implementation of lists, elements are stored into continuous locations. In order to add an element into the list at the end, we can insert it without any problem. But,

A telephone directory having n = 10 records and Name field as key. Let us assume that the names are stored in array 'm' i.e. m(0) to m(9) and the search has to be made for name "X"

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.