#header-inner {background-position: right !important; width: 100% !important;}

6/24/14

Array Data Type.

In Computer Sciences, an array type is a data type used for keeping a collection of elements of a certain data type together.

Programming languages often support this data type as part of their syntax.

There can be, for example, an array of integer numbers declared & defined as follows:

  int num[SIZE];

Where:

- int is type of elements inside array,
- num is array's name,
- SIZE is a constant, that is used in determining array's size.

Access to each of variables that is part of an array is done via the index variable or a constant, for example as follows:

  num[3]; // this is expression that gives value of a num array's variable at position 3.
  num[i]; // this is expression that gives value of a num array's variable at position
             // determined by value of 'i' variable.

  num[3] = a; // this is assignment instruction that assigns value of a variable 'a' to a num              // array at position 3.

There can be multidimensional arrays, or arrays of arrays, for example:

  int num2[SIZ_DIM_1][SIZ_DIM_2]; // 2-dimensional array declaration & definition,
             // without initialization perhaps.

  a = num2[0][0]; // expression evaluation & assignment to 'a' variable.
  num2[1][2] = a; // assignment to array variable at position (1,2).

  int num3[SIZ_DIM_1][SIZ_DIM_2][SIZ_DIM_3]; // 3-dimensional array declaration
             // & definition, without initialization perhaps.

  (...)


Access time to any of array's variables can be measured by a constant, or should be such, regardless of array's size.


See also: Basic Data Structures.

No comments:

Post a Comment