Array - It is a linear, static, type safe user defined data structure. Since array elements are stored in the RAM memory in contiguous manner its elements are accessed through its index.
Time complexity to access an array element is O(1) as address of any element is calculated directly using index and base address of given array. Using this address a given element is accessed.
Array Access method- If arr is an array, then array element at index i is represented as arr[i]
Suppose size of one array element is ELE_SIZE byte and base address of array is BASE_ADR. Then address of an array element at given index is calculated as:
Address of array element=BASE_ADR+index*ELE_SIZE
Characteristics of Array:
a. Linear - It means here data are stored sequentially in the RAM memory and there is always a unique predecessor and successor. Below is the example:
b. Static - Array is static data structure. While creating the array we have to specify its size. Once array is created its size can't be modified.
Operations on Array: