answersLogoWhite

0

A single dimensional array, or one-dimensional array, is a contiguous block of memory that contains one or more elements, each of which can store a single fixed-width value. Since each element is the same length (in bytes), the total memory consumed by the array is equal to the product of the element length and the total number of elements.

One-dimensional arrays can be thought of as being a single row or column of numbered pigeon holes (the elements), such that each hole may contain a single object (a value). The numbers identifying each element are a zero-based incremental subscript, or index number. Thus for an array of n elements, the indexes will be in the range 0 to n-1. Some languages permit the first index to be offset from 0 such that the indexes will be in the range offset to offset+n-1, however this does not alter the actual index which is always zero-based.

Arrays permit random, constant-time access to any element in the array via the element's index. When accessing an element, the return value is a reference to the first memory address of that element. This is achieved through simple pointer arithmetic, such that element i will be found at memory address (i-1) x (size of element) bytes from the start address of the array (hence the index is always zero-based, regardless of any offset that is applied).

The value's stored in the elements must be of the same intrinsic type, but can be variables or constants of any kind, including object references and pointer variables, even pointers to other arrays.

Multi-dimensional arrays are merely an extension of one-dimensional arrays, such that each element contains a reference to another one-dimensional array (each element of which may refer to yet another one-dimensional array, and so on). For instance, a two-dimensional array can be thought of as being pigeon holes arranged in rows and columns, such that every row has the same number of columns, and every column has the same number of rows. A three-dimensional array can be thought of as being a cuboid of pigeon holes. Although it's difficult to imagine a four-dimensional array in a three-dimensional space, the easiest way to think of it is as being a one-dimensional array where each element contains a three-dimensional array. More simply, a series of cuboids arranged in a row or a column.

Multi-dimensional arrays needn't reside in contiguous memory, however each individual one-dimensional array that makes up a multi-dimensional array must itself reside in contiguous memory.

Accessing the individual elements of a multi-dimensional array requires one subscript per dimension. Thus for a cuboid that has 3 rows, 3 columns and 3 tiers, the middle box will be found at zero-based index (1, 1, 1). Again, simple pointer arithmetic is employed to determine the address of the element offset from the starting address of each one-dimensional array.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Differentiate single dimensional array to double dimensional array?

A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.


What is meant by array set?

1. An array of sets. 2. An array that represents a set.


Algorithm to implement Multiple queue in single dimensional array?

algorithm on multiple queues in a single dimensional array


What is single dimentional?

A single dimension array is an array with one dimension. It is a collection in memory of one or more elements of the same type. int array[100]; declares an array of int's of size 100 elements. The elements are referenced as array[0], the first one, through array[99], the last one.


Can an array be a single column of values?

Yes.


How can you find the length of a single dimensional array in BlueJ?

array.length will return the number of elements in array.


What is meant by array with in structure in c language?

It means a structure has a member that is an array: typedef struct foo { int x[42]; // an array of 42 integers // other members... };


What is meant by distributed cache?

A distributed cache is when a cache is distributed across an array of ISA server computers. It is set up as a single logical entity which prevents duplication and also increases efficiency.


How do you merge two array without using function?

Take another array big enough to hold both array copy content of these two array into new one. You merged two array and haven't used a single function.!


What is single dimension in data structure?

Array, Stake, Queue.


How can two single dimensional array values be stored in a third single dimensional array?

You need to create a new array with enough elements to cater for both arrays. Thus if the first array has 10 elements and the second has 5, you must create a 15 element array to store both. You then copy elements from the first array into the third and immediately follow with the elements from the second. Note that the first two arrays must be of the same type. You cannot combine an array of numeric values with an array of strings, for instance.


How do arrays differ from single memory position variables?

A single memory position variable can store only one value of its type. An array can store n number of values, where n is the size of the array.