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
Write the algorithm for Binary search. Also apply this algorithm on the following data. 22, 44, 11, 88, 33, 55, 77, 66

Your first task will be to come up with an appropriate data structure for representing numbers of arbitrary potential length in base 215. You will have to deal with large negative

In the array implementation of the lists, we will use the array to hold the entries and a separate counter to keep track of the number of positions are occupied. A structure will b

Define about the inheritance hierarchy Languages Eiffel and D provide constructs in language for invariants and pre- and post conditions which are compiled into the code and ar

Example which cause problems for some hidden-surface algorithms Some special cases, which cause problems for some hidden-surface algorithms, are penetrating faces and cyclic ov

Explain in detail about the Ruby arrays Ruby arrays have many interesting and powerful methods. Besides indexing operations which go well beyond those discussed above, arrays h

What is Ruby Ruby has numerous simple types, including numeric classes such as Integer, Fixnum, Bignum, Float, Big Decimal, Rational, and Complex, textual classes like String,

Explain the Memory Function method The Memory Function method seeks to combine strengths of the top  down and bottom-up approaches  to  solving  problems  with  overlapping  su

This is a unit of which targeted on the emerging data structures. Red- Black trees, Splay trees, AA-trees & Treaps are introduced. The learner must explore the possibilities of app

Q. What do you mean by the best case complexity of quick sort and outline why it is so. How would its worst case behaviour arise?