Why is the time complexity of inserting an array O (n) and not O (n + 1)?
I just started looking into the data structure and, going through the array insertion, wondered why the time complexity of array insertion is O (n) and not O (n + 1)?
At best, when the insert is in last place, the time complexity is O (1). I am assuming we are considering 1 for element insertion since no elements are being moved here. Worst case considering we need to move n elements and then insert a new element. Should the time complexity be O (n + 1)? n to move items and 1 to insert.
Help is greatly appreciated. Thank.
+1
source to share