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

Parallel implementation of the raytracer, You are supposed to do the follow...

You are supposed to do the following: Write a parallel implementation of the raytracer using pthreads. Measure and compare the execution times for (i) the sequential ver

Traversing a binary search tree, Binary Search Tree let three types of trav...

Binary Search Tree let three types of traversals by its nodes. They are: Pre Order Traversal In Order Traversal Post Order Traversal In Pre Order Traversal, we ca

Structured programming, What do you understand by term structured programmi...

What do you understand by term structured programming? Explain the structured programming as well.                                 Ans. S tructured Programming is expla

How can a lock object be called in the transaction, How can a lock object b...

How can a lock object be called in the transaction? By calling Enqueue and Dequeue in the transaction.

Determine the precondition of a binary search, Determine the precondition o...

Determine the precondition of a binary search For instance, precondition of a binary search is that array searched is sorted however checking this precondition is so expensive

Construction of a binary tree , Q. Construct a binary tree whose nodes in i...

Q. Construct a binary tree whose nodes in inorder and preorder are written as follows: Inorder : 10, 15, 17, 18, 20, 25, 30, 35, 38, 40, 50 Preorder: 20, 15, 10

Define the external path length, Define the External Path Length The Ex...

Define the External Path Length The External Path Length E of an extended binary tree is explained as the sum of the lengths of the paths - taken over all external nodes- from

Determine the components of illumination, Determine the Components of Illum...

Determine the Components of Illumination The light reaching the eye when looking at a surface has clearly come from a source (or sources) of illumination and bounced off the su

Sequential files, Data records are stored in some particular sequence e.g.,...

Data records are stored in some particular sequence e.g., order of arrival value of key field etc. Records of sequential file cannot be randomly accessed i.e., to access the n th

Depth first search, DEPTH FIRST SEARCH (DFS) The approach adopted into ...

DEPTH FIRST SEARCH (DFS) The approach adopted into depth first search is to search deeper whenever possible. This algorithm frequently searches deeper through visiting unvisite

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