1.

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(n^2)My question is based upon Parallel Array in chapter Arrays Types of Data Structures & Algorithms IThe question was posed to me in an interview.

Answer»

Right OPTION is (c) O(N)

The explanation is: 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).



Discussion

No Comment Found

Related InterviewSolutions