What do you mean by an array? Give their characteristic feature?

Answer: – Array means collection. An array is used to store elements in same type. It is very popular and useful data structure and store data elements in contiguous memory location. More than one element is arranged in a sequence so it is also called a composite data structure. Array is a linear and homogeneous data structure. Homogenous means that the same types of elements are stored in it. It can be combined with non-homogenous structure and complex data structure can be created. We know that an array structure object can also be useful. Array of any standard or custom data type can be declared. The array of character type works somewhat differently from the array of int, float etc.

There are two types of array can be declared in any programming languages called one dimensional array and multi-dimensional array. One dimensional array is also called vector and multi-dimensional array is also called table or matrix. A one dimensional array does not have any corresponding elements; it has only one row of elements. Two dimensional arrays on the other hand, can be thought of as rectangular display of elements with rows and columns. Multi-dimensional array is a collection of two or more than one dimensional array. In the multi-dimensional array, row is constant but column changes in each row. A two dimensional array clearly show the difference between logical assumption and physical representation of data. The computer memory is linear and whatever may be the type of array one two or multi-dimensional it is stored in contiguous memory location.

Characteristics of array: –

  1. Array elements are stored in successive memory location.
  2. Once the array is declared, its lowest bound cannot be changed, but the upper bound can be expended with C++ compiler. The array name itself is a constant pointer and we cannot modify it. Therefore the lowest bound of an array cannot be expanded.
  3. We know that the array itself is a pointer. Though it is pointer, it does not need the “*” operator. The square bracket [] automatically denote that the variable is a pointer.
  4. All the elements of an array share the same name, and they distinguished from one another with the help of the element number.
  5. The mount of memory required for an array depends upon the data type and the number.
  6. Operations such as insertion and deletion of elements done with a list cannot be done with an array once an array is created, we cannot remove or insert memory locations. An element can be deleted or replaced but the memory location remains as it is.
  7. When an array is declared and not initialized, it contains garbage values. If we declare an array as static, all elements are initialized to zero. However, the values of static type data persist and remain in the memory as long as the program executes. To overcome this problem, we initialize the first element of an array with zero or any other number. All the remaining elements are automatically initialized to zero, provided that the initialization is done in the declaration statement of array.
Advertisements