• Array is a data structure used to store homogeneous elements at contiguous locations.
• The size of an array must be provided before storing data.

1. Random access is possible.
2. Required fixed memory.

#### Arrays have following limitations:

1. The size of the arrays is fixed: So we must know the upper limit on the number of elements in advance. Also, generally, the allocated memory is equal to the upper limit irrespective of the usage.
2. Deletion and Insertion are expensive. Inserting a new element in an array of elements is expensive because the room has to be created for the new elements and to create room existing elements have to shift.
• e.g. For example, in a system if we maintain a sorted list of IDs in an array arrayExample[] = [100, 103, 105, 200, 204].
• Insertion: if we want to insert a new value 102, then to maintain the sorted order, we have to move all the elements after 100.

• Deletion: To delete 103 in arrayExample[], everything after 101 has to be moved.

## Complexity of Array Data Structure

#### Array

Θ(1) Θ(n) Θ(n) Θ(n) O(1) O(n)  O(n) O(n) O(n)

#### Explanation:

Let the size of the array be 'n'.
Accessing Time:

O(1)  - This is possible because elements are stored at contiguous locations

Search Time:

O(n) for Sequential Search
O(log n) for Binary Search if Array is sorted

Insertion Time:

O(n) - The worst case occurs when insertion happens at the Beginning of an array and requires shifting all of the elements.

Deletion Time:

O(n) -  The worst case occurs when deletion happens at the Beginning of an array and requires shifting all of the elements