Question discussion

[Added later – this question is not part of the original paper]What is the worst-case time complexity of bubble sort for n elements?

359264Medium DSSSB TGT Computer Science 0 replies 0 views
0

[Added later – this question is not part of the original paper]

What is the worst-case time complexity of bubble sort for n elements?

  • AO(n)
  • BO(log n)
  • CO(n log n)
  • DO(n²)
Correct answer: D

Explanation

Bubble sort compares adjacent pairs in nested passes, which takes about n²/2 comparisons in the worst case: O(n²).

Discussion 0

Nobody has replied yet. Start the discussion!