How many passes does bubble sort need, at most, to sort a list of n items?

  1. log2 n
  2. n - 1
  3. n
  4. 2n
Answer

B) n - 1

After each pass one more item is in its final place; after n-1 passes all are sorted. SLO CS-11-B-02 · Understanding

Computer Science MCQ · More Unit 2: Computational Thinking and Algorithms MCQs · Practise