Question 12Asked in DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3

What is the worst case time complexity of bubble sort?

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

Correct answer: (C) O(x²)

Explanation

In the worst case (reverse-sorted input) bubble sort makes n(n−1)/2 comparisons and swaps, so it is O(x²) with x elements.

From DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 3

This is question 12 of DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 3. 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.