Multidimensional array, Data Structure & Algorithms

Assignment Help:

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.    

Ans.

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.


Related Discussions:- Multidimensional array

Creation of doubly linked list, Program: Creation of Doubly Linked List ...

Program: Creation of Doubly Linked List OUTPUT Input the values of the element -1111 to come out : 1 Input the values of the element -1111 to come out : 2 Inpu

Compare and contrast various sorting techniques, Q. Compare and contrast va...

Q. Compare and contrast various sorting techniques or methods with respect to the memory space and the computing time.

Explain principle of optimality, Explain principle of Optimality It ind...

Explain principle of Optimality It indicates that an optimal solution to any instance of an optimization problem is composed of  optimal solutions to its subinstances.

Determine relevancy and relative position of two polygons, Comparison Techn...

Comparison Techniques There are several techniques for determining the relevancy and relative position of two polygons. Not all tests may be used with all hidden-surface algori

Steps of pre-order traversal, Pre-order Traversal The method of doing a...

Pre-order Traversal The method of doing a pre-order traversal iteratively then has the several steps(suppose that a stack is available to hold pointers to the appropriate nodes

Interest, I =PR/12 Numbers of years .Interest rate up to 1yrs ...

I =PR/12 Numbers of years .Interest rate up to 1yrs . 5.50 up to 5yrs . 6.50 More than 5 yrs . 6.75 design an algorithm based on the above information

Postfix expression, : Write an algorithm to evaluate a postfix expression. ...

: Write an algorithm to evaluate a postfix expression. Execute your algorithm using the following postfix expression as your input: a b + c d +*f ­ .

Implement the physat algorithm, The first assignment in this course require...

The first assignment in this course required you to acquire data to enable you to implement the PHYSAT algorithm (Alvain et al. 2005, Alvain et al. 2008) in this second assignment

Define threaded binary tree, Threaded Binary Tree:- By changing the NUL...

Threaded Binary Tree:- By changing the NULL lines in a binary tree to special links known as threads, it is possible to perform traversal, insertion and deletion without using

C++ function, Write c++ function to traverse the threaded binary tree in in...

Write c++ function to traverse the threaded binary tree in inorder traversal

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