ARRAY

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).

INITIALIZATION - int arr[size] = {comma separated values};

REAL LIFE EXAMPLE OF ARRAY

REAL LIFE EXAMPLE - fruits = [name of fruits separated by commas];

FEATURES OF ARRAY

FEATURES OF ARRAYS - Same data type, Fixed size, Indexed access, Fast access, Efficient memory usage, Easy to loop through, Supports sorting and searching, Temporary storage in RAM, Can be multidimensional, Supported in most programming languages.

OPERATIONS IN AN ARRAY

INSERTION IN ARRAY

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)

DELETION IN ARRAY

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)

SEARCHING IN ARRAY

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)

SORTING IN ARRAY

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)


                

                

                

            

ARRAY COMPLEXITIES IN A GO...

COMPLEXITIES - PREVIEW UNAVAILABLE
HOME TOP OF THE PAGE