Question 13Asked in UGC NET Computer Science, June 2017 (Paper II & III, Selected Questions)

Which of the following is true for computation time in insertion, deletion and finding maximum and minimum element in a sorted array?

  1. AInsertion – O(1), Deletion – O(1), Maximum – O(1), Minimum – O(1)
  2. BInsertion – O(1), Deletion – O(1), Maximum – O(n), Minimum – O(n)
  3. CInsertion – O(n), Deletion – O(n), Maximum – O(1), Minimum – O(1)
  4. DInsertion – O(n), Deletion – O(n), Maximum – O(n), Minimum – O(n)
Show answerHide answer

Correct answer: (C) Insertion – O(n), Deletion – O(n), Maximum – O(1), Minimum – O(1)

Explanation

In a sorted array, insertion and deletion take O(n) in the worst case (elements must be shifted), while the minimum and maximum are always at the two ends, so finding them takes O(1).

From UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions)

This is question 13 of UGC NET Computer Science PYQ, June 2017 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.