[Solved] What is the worst case time complexity of inserting an element into the sorted array?

What is the worst case time complexity of inserting an element into the sorted array?

a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)

Answer: c
Explanation: In the worst case, an element must be added to the front of the array, which means that the rest of the elements have to be shifted, hence the worst-case time complexity becomes O(n).

Comments