What is the worst case time complexity of inserting an element into the sorted…
2024
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)
Attempted by 900 students.
Show answer & explanation
Correct answer: C
Answer: c
Explanation: In the worst case, an element must added to the front of the array, which means that rest of the elements have to be shifted, hence the worst case time complexity becomes O(n).