Question 51

Computer Awareness Arrays Medium

Which of the following operations is not ( O(1) ) for an array of sorted data? You may assume) that array elements are distinct

(A) Find the ith largest element
(B) Delete an element
(C) Find the ith smatlest element
(D) All of the above
View Dynamic Solution & Explanation
Correct Solution: Option B

Step-by-step Solution:

1. Find the \( i^{th} \) largest element: \[\] In a sorted array, finding the \( i^{th} \) largest element can be done directly by indexing, which is ( O(1) ). \[\] 2. Delete an element: \[\] Deleting an element from a sorted array requires shifting all elements after the deleted element to maintain the sorted order. This operation has a time complexity of ( O(n) ), not ( O(1) ). \[\] 3. Find the \( i^{th} \) smallest element: \[\] In a sorted array, finding the \( i^{th} \) smallest element can be done by simple indexing, which is ( O(1) ). \[\] Correct Option: (b)