Multidimensional array in one dimensional array, Data Structure & Algorithms

Q. By giving an example show how multidimensional array can be represented in one the dimensional array.                                                                            

Ans:

Multidimensional array: Multidimensional arrays can be defined as "arrays of arrays". For example, a bidimensional array may be imagined as a bidimensional table made of the elements, all of them of the same uniform data type.

int arr[3][5]; represents a bidimensional array of 3 per 5 elements of the type int. Similarly a three dimensional array such as

int arr[3][4][2]; represent an outer array of the three elements , each of which is a two dimensional array of the four rows, each of which is a one dimensional array of the five elements.

Multidimensional arrays are not restricted to the two or three indices (which means two dimensional or three dimensional). They may contain as many indices as required. Moreover the amount of memory needed for an array quickly increases with the each dimension.
For example: char   arr   [100][365][24][60][60];declaration  would   consume   more   than the  3 gigabytes of the memory.

The memory does not have rows and columns, so whether it is a one dimensional array or two dimensional arrays it does not matter, the array elements are stored linearly in the one continuous chain. For example, the multidimensional array

int arr[3][4][2]= {

{ {1,2},{3,4},{5,6},{7,8} },

{ {9,1},{1,2},{3,7},{4,7} },

{ {6,1},{18,19},{20,21},{22,23} },

}; is stored in memory just like the one-dimensional array as follows:

67_Multidimensional array.png

Multidimensional arrays are just an abstraction for the programmers, since we can obtain the same results with an easy array just by placing a factor between its indices.

Posted Date: 7/11/2012 1:27:06 AM | Location : United States







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

Write discussion on Multidimensional array in one dimensional array
Your posts are moderated
Related Questions
Abstract Data Types :- A useful tool for specifying the logical properties of a data type is the abstract data type or ADT. The term "abstract data type" refers to the basic mathem

since the gregorian calendar was introduced in 1752,a leap year occurs every 4 years.you are to write a pseudo code to find out whether a year is a leap year.your progrm should dis

The below formula is used to calculate n: n = (x * x)/ (1 - x). Value x = 0 is used to stop the algorithm. Calculation is repeated using values of x until value x = 0 is input. The

Read the scenario (Pickerings Properties). (a) List the functions of the system, as perceived by an external user. (b) List the external entities. Note that because we are mo

A linear collection of data elements where the linear node is given by means of pointer is known as Linked list

A queue is a, FIFO (First In First Out) list.

Q. What is the smallest value of n such that an algorithm whose running time is 100n2 runs faster than an algorithm whose running time is 2n on the same machine.    A n

For the following graph find the adjacency matrix and adjacency list representation of the graph.

how to write a pseudo code using Kramer''s rule

If preorder traversal and post order traversal is given then how to calculate the pre order traversal. Please illustrate step by step process