answersLogoWhite

0


Best Answer

A matrix (two dimensional array) is a group of lists, or arrays that are organized into one data set. To understand them, first look an example of the standard one dimensional array:

Array "A":

16

8

99

0

5

You can reference any point in the "array" by naming the array and following it with a number representing the position of a piece of data on the list. The first data on the array is represented with a "0", the second with a "1", and so on. For example, A[2] (in bold) represents 99 because it is the third figure of array A. You could imagine the references of the above table as the following:

Array "A":

[0]

[1]

[2]

[3]

[4]

A matrix is a set of arrays. Visualize the following table:

Matrix "B":

16 17 9

8 88 74

99 12 21

0 6 40

5 19 18

There are 3 different arrays in a single data set, "B". In Array A, you could reference any data by naming the point on the list, such as "1" or "3". However, with a matrix, you must give both a row and a column. You can reference data on a matrix in the following format:

MatrixName[row][column]

For example, B[3][2] would represent 40 because it is the it is on the fourth row down and the third column. Remember, matrix references also start at zero, not one! You can reference any of the data on this table with this chart:

Matrix "B":

[0][0] [0][1] [0][2]

[1][0] [1][1] [1][2]

[2][0] [2][1] [2][2]

[3][0] [3][1] [3][2]

[4][0] [4][1] [4][2]

Two-dimensional arrays are used everywhere, but are especially prevalent in computer programming and accounting. If you know any programmers, ask them the last time the last time they used a matrix- I'm sure they'll give you plenty of examples!

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

Array is a variable which holds the subscript it is similar data type is called array

one dimensional array:It is an variable which holds only one subscript by similar data types

syntax:data type,variable,name [size];

program:#include<stdio.h>

#include<conio.h>

void main()

{

int i;

float x[10],value,total;

clrscr();

printf("enter five real numbers");

for(i=0;i<10;i++)

{

scanf("%f",value);

x[i]=value;

}

total=0.0;

for(i=0;i<10;i++)

total=total+x[i]+x[i];

printf("/n")

for(i=0;i<10;i++)

printf("[%2d]=%5.2f/n",i+1,x[i];

printf("total=%2f/n",total);

}

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

There is no practical difference. A multi-dimensional array is simply an array where every element is itself an array (an array of arrays). Fixed-size multi-dimensional arrays are always allocated contiguously just as if they were a one-dimensional array, the size of which is the product of its dimensions. Variable size arrays can also be allocated contiguously, however when they are extremely large or if the size in any one dimension is variable, it is often better to split the array into separately allocated arrays and using another array to manage each of the allocations.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

If you imagine a standard chessboard, a one-dimensional array representing each of the squares on the board would need to contain 64 elements (numbered 0 to 63).

However, because the board itself is two dimensional, it makes more sense to refer to individual squares by the intersection of the square's row and column. Thus a two dimensional array will contain 8 rows and 8 columns (each of which is numbered 0 to 7).

Another way to look at a two-dimensional array is to imagine that first dimension represents a one-dimensional array of rows while each of these row elements is itself a one-dimensional array of squares, with one square per column. This may seem counter-intuitive at first, but when dealing with dynamic arrays, that may be exactly how the array is allocated. That is, while a static array always occupies contiguous memory locations (regardless of how many dimensions), a dynamic array is often allocated one dimension at a time. Each one-dimensional array will itself be contiguous, but the array as a whole may not be.

However, regardless of how the memory is mapped, the dimensions make it easier to determine which individual element you are accessing. If our board were declared as a one-dimensional array, accessing element[24] doesn't immediately tell us which row or column that element resides in. Whereas element[4][0] tells us exactly which row and column the square is in. These are, in fact, the same square (and therefore the same element), but the second is more intuitive as there's a direct correlation between the array and the object it represents (an 8x8 chessboard).

Arrays aren't restricted to just one or two dimensions. A three-dimensional array might be used to represent a cuboid. For instance, a standard 3x3x3 Rubik's cube might be represented by a three-dimensional array where each dimension has three elements (if we conveniently ignore the fact a Rubik's cube is not a real cube with 27 individual cubes).

We can also go beyond 3-dimensions without the need for a Degree in Theoretical Physics. The trick is to remember that each dimension is itself a one-dimensional array. Therefore a four-dimensional array can be thought of as a one-dimensional array where each element is a three-dimensional array. A five-dimensional array is therefore a one-dimensional array where each element contains a four-dimensional array, and so on.

Once you're familiar with this way of thinking, it no longer matters if the array is allocated contiguously or separately. Every element is addressable by its unique index, whether that index contains one or multiple dimensions.

Dynamic arrays are a bit more difficult to work with, particularly when there are multiple dimensions to consider. However, the simplest way to manage them is by allocating a one-dimensional array for the entire array (multiplying all the dimensions together), and then use a separate array of pointers to divide the larger array into its individual dimensions, and finally maintain a pointer-to-pointer variable to refer to the array of pointers.

So, going back to our chessboard example, if we suppose the chessboard is not restricted to 8x8 squares, a static array would be no use as it couldn't cater fora 9x9 board. Se we need a dynamic array. We begin by declaring a pointer-to-pointer and allocate a 9-element array of pointers to it. We then allocate an 81-element array to the first pointer. The other 8 pointers are then assigned an address within the 81-element array, such that each is offset by 9 elements from the previous element.

Now we can access the array itself using the pointer-to-pointer, just as if it were a static array. If the pointer-to-pointer were named board, then board[1][2] would access the square in the second row, third column. This works because the [1] refers to the second pointer in the pointer array (which points to the second row in the array), while the [2] refers to the third element in that row. The language is such that we need not concern ourselves with the fact an array of pointers exists but, without it, we'd not be able to access the array multi-dimensionally.

An alternative way to allocate the array would be to allocate individual one-dimensional arrays to each pointer in the pointer array (where each array represents a row on the board). However, because this would require 9 separate allocations, the creation of the array as a whole takes much longer than it would with the single allocation. In addition, releasing the array is much simplified as we only have to release the entire array (pointed to by the first element in the pointer array), and then release the pointer array itself. Using individual allocations would mean releasing each pointer in the pointer array before release the pointer array itself.

Regardless of how the array is allocated, accessing the individual elements is achieved in the same way, via the pointer-to-pointer. It does not matter if the array resides in contiguous memory or not -- the pointer array takes care of all that for us automatically.

Moving onto three dimensions and beyond is only complicated by the fact the pointer-to-pointer requires an extra level of indirection for each additional dimension. That is, a pointer-to-pointer-to-pointer is required for a three-dimensional array, which points to an array of pointer-to-pointer, each of which points to an array of pointer, each of which points to an appropriate offset within the actual array.

Why bother with just two? Think about 27+(just to begin with) different dimensions & inter Universal expansionsional change regarding 'PURE ENERGY the form of Dark Matter & it's direct correlation with it's inter-actional Relationship to CREATION & ALL Eternity should be able to do that over lunch:)) 'Doc' is just fine:)

Pick your Wavelength & the several Frequencies contained therein..........& GO FOR IT. You have talent.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

The short answer is that a single dimension array has just one dimension while a multi-dimensional array has 2 or more dimensions.


A single-dimension array can be thought of as being a row of numbered pigeon holes, where the first pigeon hole is numbered 0. This is what is meant by a zero-based index.


A multi-dimensional array can be thought of as being an array of arrays. For example, a two-dimensional array is a one-dimensional array of one-dimensional arrays. A chessboard is an example of a two dimensional array, where each square is identified by an unique row and column identifier. Two-dimensional arrays are often used to represent tables and matrices.


A three-dimensional array can be thought of as being a 3D cuboid, where each cell can be identified by three dimensions (such as width, height and depth). However, it is more accurate to state that a three dimensional array is a one-dimensional array of two-dimensional arrays, because this then makes it easier to comprehend four dimensional arrays (a one-dimensional array of three dimensional arrays) and so on. Another way to think of four dimensional arrays is as a row of cuboids. A five-dimensional array is therefore a table of cuboids, while a six-dimensional array becomes a cuboid of cuboids.


Regardless of the number of dimensions, each element in an array is accessed through the array indices, such that there is one index per dimension. However, since each element within a dimension has the same number of elements, you can also use pointer arithmetic to navigate the array. Indeed, that is exactly what happens Behind the Scenes -- the index values are just sugar-coating to make arrays easier to work with.


This answer is:
User Avatar

User Avatar

Wiki User

14y ago

For the computer, not much. Every array, no matter how many dimensions it has, is stored as a one-dimensional array. However, the benefit is that it allows the data to be sorted in a way that is possibly clearer for the programmer or user. All the computer does is multiply all those indexes by the bit sizes of their blocks, and add them together to find the address of the data it needs. So the trade-off of multidimensional arrays is slowing down the program a bit to make it's working a bit simpler for the user/programmer.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

The number of dimensions.

Example:

int single[21];

int matrix[10][10], cube[2][2][2];

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

two dimension array used to enter the two field of data that is in row size and column size

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Number of dimensions.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is Difference between one dimensional array and two dimensional?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Explain the Different types of array?

one dementional array and two dementional array


What are 3 different ways to implement an array of order 4x8?

An array of order 4x8 can either be implemented as a one-dimensional array of order 32 or as a one-dimensional array of order 4, where each element is a one-dimensional array of order 8. In either case, the 32 data elements are allocated contiguously and there is no difference in performance. A third way is to implement the one-dimensional array of order 4 as an array of pointers to separately allocated one-dimensional arrays of order 8. The order 4 array is contiguous as are the order 8 arrays, however they need not be contiguous with one another other. This is the least efficient implementation due to the additional level of indirection required to navigate the array.


How will you initialize a 2-d array?

All arrays are one-dimensional. A two-dimensional array is simply a one-dimensional array of one-dimensional arrays: int a[2][3]; This is an array of 2 elements where each element is itself an array of 3 integers. In other words it is an array of 6 integers. The two dimensions simply allow us to split the array into two sub-arrays of 3 elements each.


Pointer to 3 dimensons array?

If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.

Related questions

How does two dimensional array differ from single dimensional array?

A one dimensional array is a scalar value repeated one or more times.A two dimensional array is an array of one dimensional arrays.A three dimensional array is an array of two dimensional arrays, and so forth.The one dimensional array is like a list of things, where the two dimensional array is like an array of things. (Think one row of a spreadsheet versus the whole spreadsheet.)[addendum]Every level of array depth is also a level of pointer depth. For example: A 3 dimensional int array is an int***. So a one dimensional int array is an int*, and a two dimensional int array is an int**. This is only important if you are doing pointer work, but it can become very important.


What is single dimensional array in c plus plus?

A one dimensional array is an array of objects that goes in one "direction". Any array with only one [] is a one dimensional array. For example: int numbers[6]; is a one dimensional array. int numbers[6][3]; is a two dimensional array.Graphical terms:One dimensional array[4]:14 - 75 - 8164 - 234Two dimensional array[2][3]:47 - 178108 - 8517 - 128It didn't come out quite how I wanted it...


What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Explain the Different types of array?

one dementional array and two dementional array


What is a multi array?

A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right. A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables. Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.


What are 3 different ways to implement an array of order 4x8?

An array of order 4x8 can either be implemented as a one-dimensional array of order 32 or as a one-dimensional array of order 4, where each element is a one-dimensional array of order 8. In either case, the 32 data elements are allocated contiguously and there is no difference in performance. A third way is to implement the one-dimensional array of order 4 as an array of pointers to separately allocated one-dimensional arrays of order 8. The order 4 array is contiguous as are the order 8 arrays, however they need not be contiguous with one another other. This is the least efficient implementation due to the additional level of indirection required to navigate the array.


How many types of arrays in c?

An array is simply a contiguous block of memory containing two or more elements. There are two types of array: a static array which is allocated on the stack at compile time; and a dynamic array which is allocated on the heap at runtime. Both can be one-dimensional or multi-dimensional. A one-dimensional array can be likened to a row (or column) of chessboard squares, with as many squares as required to store all the elements. A multi-dimensional array is any array with two or more dimensions. A two-dimensional array can be likened to the whole chessboard, where any square can be identified by its row and column index. However the dimensions needn't be equal. A two-dimensional array can also be imagined as a one-dimensional array where every element is simply another one-dimensional array. Three-dimensional arrays can be likened to a cube, or as a one-dimensional array of two-dimensional arrays. A four-dimensional array can be linked to a one-dimensional array of three-dimensional arrays, and so on. Although every one-dimensional array must be allocated in contiguous memory, multi-dimensional arrays can be dynamically allocated so that each dimension is itself a separately allocated one-dimensional array of pointers to the next dimension, making it possible to allocate extremely large arrays over a series of smaller allocations rather than as a single contiguous block.


What is one dimentional array?

A One dimensional array is one in which a set of values are present in it. Ex: int[] myArray = new int[4]; The above statement creates a one dimensional array that can hold 4 values.


How will you initialize a 2-d array?

All arrays are one-dimensional. A two-dimensional array is simply a one-dimensional array of one-dimensional arrays: int a[2][3]; This is an array of 2 elements where each element is itself an array of 3 integers. In other words it is an array of 6 integers. The two dimensions simply allow us to split the array into two sub-arrays of 3 elements each.


Pointer to 3 dimensons array?

If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.


Columns and rows in c programming?

Do you perhaps mean -- a two-dimensional array? A two dimensional array is nothing more than a one-dimensional array where every element is a one-dimensional array. int matrix[4][5]; C is a row-major language thus the first dimension refers to the number of rows. Here we have declared an array of 4 rows, where each row is an array of 5 elements of type int.


What is an array for 2 times 3?

An array of 2 times 3 is a one-dimensional array of 2 elements each of which is a one-dimensional array of 3 elements. In other words, it is an array of arrays, also known as a two-dimensional array. We can imagine a two dimensional array as being a table with rows and columns. A 2 times 3 array has 2 rows and 3 columns. Each row is itself an array of 3 elements. However, we can also say that each column is an array of 2 elements.