###### Asked in Computer Programming

Computer Programming

# What is the difference of single dimension to multi dimension array?

## Answer

###### Wiki User

###### January 16, 2015 5:22PM

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.

## Related Questions

###### Asked in Visual Basic Programming, C++ Programming

### Difference of single dimensional and multi dimensional array?

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.

###### Asked in C++ Programming

### What are types of array in c plus plus?

An array is simply a contiguous block of memory that is divided
up into one or more elements, where each element is of the same
type and size, as determined by the type specified in the array
declaration. Arrays may be single-dimension or multi-dimensional.
Multiplying the dimensions together gives the total number of
elements in the array, and multiplying by the element size gives
the total size of the array in bytes. The array name is a reference
to the start address of the array, which is also the start address
of the first element in the array. Pointing to this address with a
pointer of the same type as the elements within allows you to
navigate the array as you see fit, or you can use the array
subscript operator to specify any element within the array.
Arrays can be static (fixed size, allocated at compile time) or
dynamic (variable size, allocated at runtime). Large, dynamic,
multi-dimensional arrays are often implemented non-contiguously as
a series of smaller arrays of the same size, and using small arrays
of pointers (or pointer-to-pointer types) which point to each of
the smaller arrays. This also allows any single-dimension array to
be subdivided into a multi-dimensional array.

###### Asked in Computer Programming

### What is a multi dimensional 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.

###### Asked in C++ Programming, Active Server Pages, ASP.NET

### How many types of arrays are 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.

###### Asked in Computer Programming

### What is meant by irregular dimensional array?

An irregular dimensional array is a special type of
multi-dimensional array.
First we must understand that a multi-dimensional array is just an
array of arrays. Each element in the array is, itself, an array of
elements.
A regular multi-dimensional array will be an array of size n, with
each element containing a separate array of size m. That is, each
sub-array has the same size.
An irregular multi-dimensional array will be a multi-dimensional
array in which each sub-array does not contain the same number of
elements.
Regular array:
array[0] = new array{0, 1, 2}
array[1] = new array{3, 4, 5}
array[2] = new array{6, 7, 8}
array[3] = new array{9, 10, 11}
This regular array is an array of size 4 in which each sub-array is
of size 3.
Irregular array:
array[0] = new array{0, 1, 2}
array[1] = new array{3, 4}
array[2] = new array{5, 6, 7}
array[3] = new array{8, 9, 10, 11}
This irregular array is an array of size 4 in which the size of
each sub-array is not the same.

###### Asked in Computer Programming, C Programming, C++ Programming

### What is linear data structure?

A linear data structure is one in which, while traversing
sequentially, we can reach only one element directly from another.
Eg- Linked List, Array.
2D array, though seems to be non-linear, is actually linear data
structure. This is because memory is single dimensional and when it
is stored in the memory it is stored as a single dimension array in
either row-major or column-major format. Similarly all
multi-dimensional arrays are also linear, for the same reason.

###### Asked in Computer Programming, C Programming, Operating Systems

### What are the types of array?

There are several different types of arrays, which describe the
characteristics of the array. Arrays may be static or dynamic.
Static arrays have a predetermined size that will not change over
the course of the program's life cycle, while dynamic arrays may be
made larger or smaller as necessary while the program runs. Arrays
may be one-dimensional or multi-dimensional. An array of just one
dimension stores values in a straight line, while a
multi-dimensional array represents data that might be rectangular,
such as the dots in an image, or even 3 dimensional, such as a
multi-layer image, an animation, etc.

Load More