[Solved] In special case, the time complexity of inserting/deleting elements at the end of dynamic array is __________

In special case, the time complexity of inserting/deleting elements at the end of dynamic array is __________

a) O (n)
b) O (n1/2)
c) O (log n)
d) O (1)

Answer: a
Explanation: In general, the time complexity of inserting or deleting elements at the end of the dynamic array is O (1). Elements are added to the reserved space of the dynamic array. If this reserved space is exceeded, then the physical size of the dynamic array is reallocated and every element is copied from the original array. This will take O(n) time to add a new element at the end of the array.

Comments