What is the worst case time complexity of bubble sort?
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.
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.
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.