🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Sorting Basics: all 13 questions

Quiz: Sorting Basics · Question 4 of 13

What is the best-case time of bubble sort with the "stop if no swap" check?

What is the best-case time of bubble sort with the "stop if no swap" check?

  1. A.O(n)
  2. B.O(log n)
  3. C.O(n log n)
  4. D.O(n²)
Answer & explanation

Correct answer: O(n)

On a sorted array the first pass makes no swap, so the algorithm stops after one pass of n − 1 comparisons.

Can you get the rest right without peeking?

Take the timed Quiz: Sorting Basics quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →