After the first pass of bubble sort (ascending) on [5, 1, 4, 2, 8], the list is:

  1. [1, 4, 2, 5, 8]
  2. [1, 5, 4, 2, 8]
  3. [5, 1, 4, 2, 8]
  4. [1, 2, 4, 5, 8]
Answer

A) [1, 4, 2, 5, 8]

Swaps: (5,1), (5,4), (5,2); (5,8) stays – the largest value reaches the end. SLO CS-11-B-02

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