After the first pass of bubble sort (ascending) on [5, 1, 4, 2, 8], the list is:
- [1, 4, 2, 5, 8]
- [1, 5, 4, 2, 8]
- [5, 1, 4, 2, 8]
- [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