Introduction to Array
Array is a collection of variables of same data type that share a common name.
Array is an ordered set which consist of fixed number of elements.
Array is an example of linier data structure.
In array memory is allocated sequentially so it is also known as sequential list.
Consider Following Example in which an array of five elements is stored sequentially in memory.
In One Dimensional Array location of element A[i] can be calculated using following equation:
LOC (A[i]) = Base_Address + W * (i)
Base_Address is the address of first element in the array.
W is the word size. It means number of bytes occupied by each element.
Suppose we want to calculate the address of element A . It can be calculated as follow:
Base_Address = 2000, W=2
|LOC (A [i])||=||Base_Address + W (i)|
|LOC (A )||=||2000 + 2 (2)|