For the list [35, 9, 12, 51, 32, 21], how will the list elements look like after second pass in Bubble Sort?
For the list [35, 9, 12, 51, 32, 21], how will the list elements look like after second pass in Bubble Sort?
Solution
✅ Correct Option: 4
Bubble sort compares adjacent elements from the left and swaps them if the left one is larger. Each pass pushes the largest remaining element to the end.
| Pass | Swaps made | List after pass |
|---|---|---|
| Start | none | [35, 9, 12, 51, 32, 21] |
| 1 | 35 and 9, 35 and 12, 51 and 32, 51 and 21 | [9, 12, 35, 32, 21, 51] |
| 2 | 35 and 32, 35 and 21 | [9, 12, 32, 21, 35, 51] |
In pass 2, the pairs (9, 12) and (12, 35) need no swap. After the swaps, 35 reaches its place just before 51.
After pass , the last elements are in their final sorted positions. Here 35 and 51 are already fixed at the end.
Related questions:
2025: 13 May Shift 2
2025: 16 May Shift 1
2025: 21 May Shift 1