1. A collection of identically typed data items distinguished by their indices (or "subscripts"). The number of dimensions an array can have depends on the language but is usually unlimited.An array is a kind of aggregate data type. A single ordinary variable (a "scalar") could be considered as a zero-dimensional array. A one-dimensional array is also known as a "vector". A reference to an array element is written something like A[i,j,k] where A is the array name and i, j and k are the indices. The C language is peculiar in that each index is written in separate brackets, e.g. A[i][j][k]. This expresses the fact that, in C, an N-dimensional array is actually a vector, each of whose elements is an N-1 dimensional array. Elements of an array are usually stored contiguously. Languages differ as to whether the leftmost or rightmost index varies most rapidly, i.e. whether each row is stored contiguously or each column (for a 2D array). Arrays are appropriate for storing data which must be accessed in an unpredictable order, in contrast to lists which are best when accessed sequentially. Array indices are integers, usually natural numbers, whereas the elements of an associative array are identified by strings.
Last updated: 2007-10-12