A collection of elements of the same data type, stored in contiguous memory locations. Each element
in an
ARRAY can be accessed using its index, which is a numerical
identifier indicating its position in the
sequence.
EASY TO UNDERSTAND - An ARRAY is a list of
items stored in order, all in one place in a
computer's memory.
TECHNICAL DEFINITION -
An ARRAY stores multiple values under a single name.
All values must be of the same type (like all numbers or all letters).
Each item has an index (starting from 0).
1. AT BEGINNING - It means the element to be inserted will be inserted in the starting of the ARRAY by increasing the size by one. i.e. at index - 0.
TIME COMPLEXITY - O(1)
2. AT MIDDLE/GIVEN POSITION - It means the element to be inserted will be inserted at the given position of the ARRAY and rest of the elements next to it will shift to one place towards right by increasing the size by one. i.e. at index - position-1.
TIME COMPLEXITY - O(n)
3. AT END - It means the element to be inserted will be inserted at the last position of the ARRAY by increasing the size by one. i.e. at index - (-1).
TIME COMPLEXITY - O(1)
1. FROM BEGINNING - It means the element to be removed will be removed from the starting of the ARRAY by decreasing the size by one. i.e. at index - 0.
TIME COMPLEXITY - O(1)
2. FROM MIDDLE/GIVEN POSITION - It means the element to be deleted will be removed from the given position of the ARRAY and rest of the elements next to it will shift to one place towards left by decreasing the size by one. i.e. at index - position-1.
TIME COMPLEXITY - O(n)
3. FROM END - It means the element to be removed will be deleted from the last position of the ARRAY by decreasing the size by one. i.e. at index - (-1).
TIME COMPLEXITY - O(1)
It means the element to look out for the mentioned or needed element in the ARRAY by traversing whole array and checking each of the elements one by one. i.e. index - 0 to size-1
TIME COMPLEXITY - O(n)
It means to sort the ARRAY either in ascending or in descending order of the elements present in the ARRAY by traversing whole array. i.e. index - 0 to size-1
TIME COMPLEXITY - O(n2)