Sunday, October 11, 2009

Linear or One-dimensional Arrays

An array (of any dimension) is a linear and structured data type with the following properties and characteristics:

1. It is made up of finite n homogenous (of same type) data elements such that

a. Every data element is of fixed size. Size depends upon the specific nature of structure of the data elements.

b. The elements of the array are referenced respectively by an index set consisting of n consecutive numbers.

c. The elements of the array are stored respectively in successive contiguous memory locations. Array is a data–structure that uses memory statically unlike linked list, which is constructed on dynamic memory allocation.

2. The accessing mechanism of an array is direct access, which means we can access any element directly, without first accessing the preceding elements. The desired element is specified using an index, which gives its relative position in the collection. e.g.

A [0], A[1],…….. A[n-1]

3. Arrays are built–in data types in most of the programming languages including C and C++.

4. The length or size or number of data elements of the array, A[LB:UB], can be obtained from the index set by the formula.

Length of Array A = UB – LB + 1

where UB is the largest index, called the upper bound, and LB is the smallest index, called the lower bound, of the array. In C and C++ languages, LB is always zero.

2 comments:

  1. can u explain about n dimensional array ????

    ReplyDelete
  2. Please give some example to understand what you want to say.

    ReplyDelete