Algorithm For Insert Element Into A Array
Algorithm For Insert Element Into A Array
Insert(array, N, K, Element)
N=No. of elements
K= Position
Visual Representation
Let's take an array of 5 integers.
11, 12, 5, 90, 20.
If we need to insert an element 80 at position 2, the execution will be,
Algorithm for deleting an element from an array:
Algorithm for inserting elements into an array:
Delete (array, N, K, element)
N=No. of elements
K= Position
Visual Representation
Let's take an array of 5 elements.
11, 12, 5, 90, 20.
If we remove element 12 from the array, the execution will be,
The time complexity to insert and remove an element from the array is O(n) in the
worst case.