Multidimensional array in one dimensional array, Data Structure & Algorithms

Assignment Help:

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.


Related Discussions:- Multidimensional array in one dimensional array

Program, circular queue using c

circular queue using c

What is gouraud shading, Gouraud Shading The faceted appearance of a La...

Gouraud Shading The faceted appearance of a Lambert shaded model is due to each polygon having only a single colour. To avoid this effect, it is necessary to vary the colour ac

Implementation of stack using linked lists, In the last subsection, we have...

In the last subsection, we have implemented a stack by using an array. While a stack is implemented by using arrays, it suffers from the basic restriction of an array - i.e., its s

Program of implementation of stack using arrays, include int choice, st...

include int choice, stack[10], top, element; void menu(); void push(); void pop(); void showelements(); void main() { choice=element=1; top=0; menu()

In-order traversal, Write steps for algorithm for In-order Traversal Th...

Write steps for algorithm for In-order Traversal This process when implemented iteratively also needs a stack and a Boolean to prevent the execution from traversing any portion

Acyclic graph, Tree is a widely used data structure employed for representi...

Tree is a widely used data structure employed for representing several problems. We studied tree like a special case of acyclic graph. Though, rooted trees are most prominent of al

Define about the inheritance hierarchy, Define about the inheritance hierar...

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

Determination of time complexity, Determination of Time Complexity The...

Determination of Time Complexity The RAM Model The random access model (RAM) of computation was devised through John von Neumann to study algorithms. In computer science,

What are the objectives of visual realism applications, What are the Object...

What are the Objectives of visual realism applications After studying this unit, you should be able to know specific needs of realism, add realism to pictures by el

Illustrate the visual realism applications, Illustrate the Visual realism a...

Illustrate the Visual realism applications a)   Robot Simulations : Visualization of movement of their links and joints  and end effector movement etc. b)  CNC programs ver

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd