Question 110Asked in DSSSB TGT Computer Science, 25 Jun 2023, Shift 2 (12:30 PM)

What is the best case and worst-case complexity of selection sort?

  1. AO(n log n)
  2. BO(n)
  3. CO(n²)
  4. DO(log n)
Show answerHide answer

Correct answer: (C) O(n²)

Explanation

Selection sort always scans the whole unsorted part to find the minimum, making about n(n−1)/2 comparisons whatever the input order. So both its best and worst cases are O(n²).

From DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 2 (12:30 PM)

This is question 110 of DSSSB TGT Computer Science PYQ, 25 Jun 2023, Shift 2 (12:30 PM). 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.