← 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?
- A.O(n)
- B.O(log n)
- C.O(n log n)
- 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 →