const strings = ['a', 'b', 'c', 'd'];//push
strings.splice(2,0,'alien'); //O(n/2) -> O(n)
For unshift, when the new element is added in the front of the array, all the elements have to be re-assigned.
ex. ‘a’ (strings -> strings), ‘b’(strings -> strings)
This will happen for the every element in array. Hence the time complexity is O(n).
For splice, the assignment happens for the only half end part of the array. However, O(n/2) -> O(n). Thus time complexity will be O(n).
lookup — O(1)
push — O(1)
insert — O(n)
delete — O(n)